[Perth-pm] Using \L and \E inside a variable, inside a substitution s///

James Bromberger james at rcpt.to
Sun Oct 24 17:58:52 PDT 2010


On 25/10/2010 07:54, Neil Hunt wrote:
> You can pull out the match (i.e. $1) and pass it through a tr, which
> should achieve your goal.
> Something like the following does what you're asking:
>
> my $url = "http://www.FOo.COm/wibbLE";
> $url =~ m|(\w+)://([^/:]+)(:\d+)?/(.*)|;
> my $protocol = $1;
> my $domainName = $2;
> $uri= $4;
> $domainName=~tr/A-Z/a-z/;
>
> Note that a ' does not cause it's contents to be interpolated, you
> need to use ".

Thanks Neil,

I hadn't through to use TR (face, palm); I was pulling a set of "search"
and "replace" patterns from a database, and trying to use them all
generically ALL as a substitution, with this one special case of a case
change. Its the only time I can see a use for \[LlUu] in place of lc(),
uc(), etc....


  James

-- 
*James Bromberger*
Aus Mobile: +61 422 166 708
Email: james /_AT_/ rcpt.to, Web: www.james.rcpt.to
<http://www.james.rcpt.to/>
MSN: james/_AT_/rcpt.to, AIM: JamesEBromberger, Skype: james.bromberger
(/_AT_/ -> @)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.pm.org/pipermail/perth-pm/attachments/20101025/c1cd4715/attachment.html>


More information about the Perth-pm mailing list