Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: I think regex Should Help Here... but How!?

by RichardK (Priest)
on Feb 15, 2014 at 12:30 UTC ( #1075044=note: print w/ replies, xml ) Need Help??


in reply to I think regex Should Help Here... but How!?

As you're only trying to match the beginning of a string with no wildcards using index seems like a simpler approach.

foreach (@items) { say "$_ match" if index($_,$master) == 0; }


Comment on Re: I think regex Should Help Here... but How!?
Download Code
Re^2: I think regex Should Help Here... but How!?
by AnomalousMonk (Abbot) on Feb 15, 2014 at 13:00 UTC

    This from ozboomer's OP

    if ($str =~ /^$buf/i) { ... }
    indicates a case-insensitive match is required, so index would not be appropriate.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (8)
As of 2014-12-27 00:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (176 votes), past polls