Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: perlfunc index name conflict

by chuckbutler (Prior)
on Sep 23, 2012 at 22:50 UTC ( #995267=note: print w/replies, xml ) Need Help??


in reply to perlfunc index name conflict

If you would like to use supplied Perl index function, qualify it CORE::index.

Also, the second parameter should be a substring to match, not a regular expression. See index.

Good luck. -c

Replies are listed 'Best First'.
Re^2: perlfunc index name conflict
by dpath2o (Acolyte) on Sep 24, 2012 at 00:11 UTC
    Thank you CORE::index has solved my problem.
Re^2: perlfunc index name conflict
by Anonymous Monk on Sep 24, 2012 at 00:09 UTC

    the second parameter should be a substring to match, not a regular expression

    Well, /(\w+)/ will return a substring

      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://995267]
help
Chatterbox?
[virtualsue]: holli about half
[choroba]: "Tatsächlich, das ist die Knochenstruktur eines Bettlers!" ??
shmem bows. Thank you
[marto]: slowclap.gif
[marto]: animated gif in question...
[1nickt]: Interesting article on the Coming Software Apocaplyse that I found while following one of eyepopslikeamosqui to's posts. Posits that no one can guarantee the quality of, or even understand, the 100 million lines of code in a mo
[holli]: you know, monk days are fun and all. but too many of them are bad for your health
[1nickt]: ...modern car. Suggests using TLA+ or other software modeling language to autogenerate code.
1nickt is not sure more and more layers separating the programmer from the program is the right way to go...
[holli]: happy one, shmem ;)

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (12)
As of 2017-11-21 12:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    In order to be able to say "I know Perl", you must have:













    Results (301 votes). Check out past polls.

    Notices?