Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: Why this simple code doesn't work?

by Corion (Pope)
on Mar 02, 2012 at 10:29 UTC ( #957432=note: print w/ replies, xml ) Need Help??


in reply to Why this simple code doesn't work?

See perlop on m?...? (as opposed to m/.../).


Comment on Re: Why this simple code doesn't work?
Select or Download Code
Re^2: Why this simple code doesn't work?
by uksza (Monsignor) on Mar 02, 2012 at 10:33 UTC
    Och
    If "?" is the delimiter, then a match-only-once rule applies
    thank you!
      #!/usr/bin/perl -w use strict; use 5.10.0; while (<DATA>) { chomp; process_path($_); } sub process_path { my $path = shift; if ( $path =~ m{^.*/home/(.*)/\.forward} ) # m[...] or # m|...| works also { say "i've got >$1<"; } else { say "ups >$path<"; } } =prints i've got >aaa< i've got >bbb< i've got >ccc< i've got >ddd< =cut __DATA__ /home/aaa/.forward /home/bbb/.forward /home/ccc/.forward /home/ddd/.forward

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (14)
As of 2014-08-28 16:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (264 votes), past polls