Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: The 'g' modifier in compiled regex

by ikegami (Patriarch)
on Apr 09, 2007 at 05:27 UTC ( [id://608930]=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    $str = 'Nothing but perl can parse Perl';
    
    ...
    
    print($str =~ /perl/i ?1:0,"\n");      # Prints '1'
    print($str =~ /noth/i ?1:0,"\n");      # Prints '1'
    
  2. or download this
    $str = 'Nothing but perl can parse Perl';
    
    ...
    while (/perl/i) {
       # Loops forever
    }
    
  3. or download this
    my @matches = ($g ? /$re/g : /$re/);
    
  4. or download this
    for (...) {
       my ($re, $g) = @$_;
       my @matches = ($g ? /$re/g : /$re/);
       ...
    }
    
  5. or download this
    >perl -le"print qr/.../s"
    (?s-xim:...)
    

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (4)
As of 2024-04-25 15:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found