Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical

Re: unconventional string substitutions

by hipowls (Curate)
on Mar 20, 2008 at 07:08 UTC ( #675171=note: print w/ replies, xml ) Need Help??

in reply to unconventional string substitutions

Another approach is to use embedded flags, it is possible to embed all the modifiers except /g and /c

#!/net/perl/5.10.0/bin/perl use strict; use warnings; use 5.010_000; my $string = 'This is perl, the Perl interpreter'; foreach my $flag ( '', 'i' ) { if ( my ($match) = $string =~ /(?$flag:(Perl))/ ) { print "$match\n"; } } Perl perl __END__

Update: also doesn't work with /c, add it above.

Comment on Re: unconventional string substitutions
Download Code

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://675171]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (8)
As of 2015-11-26 16:42 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (703 votes), past polls