Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number

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.

Comment on Re^3: perlfunc index name conflict
Download Code

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (9)
As of 2015-11-27 15:36 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 (731 votes), past polls