Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re^3: perlfunc index name conflict

by AnomalousMonk (Canon)
on Sep 24, 2012 at 08:30 UTC ( #995310=note: print w/replies, xml ) Need Help??


in reply to Re^2: perlfunc index name conflict
in thread perlfunc index name conflict

In scalar context such as supplied by index, a successfully matching regex will return 1, which will be stringized to '1' for the substring for which to search:

>perl -wMstrict -le "my $str = 'abc1def'; $_ = 'xyz'; ;; print 'index: ', index $str, /(\w+)/; print qq{captured: '$1'}; " index: 3 captured: 'xyz'

An unsuccessful regex match returns the empty string in scalar context.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://995310]
help
Chatterbox?
[thezip]: How goes it, Corion?
[Corion]: thezip: Quite good, after a one week vacation in the sun ;)
[Corion]: I hope you're well too!
[thezip]: Where did you go? We've already set a record for all-time February rainfall here.

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (11)
As of 2017-02-23 16:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Before electricity was invented, what was the Electric Eel called?






    Results (349 votes). Check out past polls.