Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

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?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (9)
As of 2015-07-07 07:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (87 votes), past polls