Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things

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

by RichardK (Parson)
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; }

Replies are listed 'Best First'.
Re^2: I think regex Should Help Here... but How!?
by AnomalousMonk (Canon) 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?

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

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (14)
As of 2016-10-27 20:28 GMT
Find Nodes?
    Voting Booth?
    How many different varieties (color, size, etc) of socks do you have in your sock drawer?

    Results (371 votes). Check out past polls.