[Omaha.pm] s(a)(AAA) -- wow

Jay Hannah jay at jays.net
Fri Jul 9 16:45:07 CDT 2004


Wow. I knew you could change / to any character for matching and 
substituting...

    s///  can be written as  s###  or  sxxx

But I've never seen parens used before!

test code
--------------------
% cat j.pl
#!/usr/bin/perl

my $j = "blah away";
$j =~ s(a)(AAA)g;
print "$j\n";

% perl j.pl
blAAAh AAAwAAAy
--------------------

Actual code I ran into in Pod::Tree::PerlPod:

     my $perl_dir = $perl_pod->{perl_dir};
     my $html_dir = $perl_pod->{html_dir};
        $dest     =~ s(^$perl_dir)($html_dir);

Wow.....

hese work too:

s[a][AAA]g
s{a}{AAA}g

What arcane crap *can't* you do in Perl?

Laugh,

j




More information about the Omaha-pm mailing list