Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

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

by RichardK (Vicar)
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
Replies are listed 'Best First'.
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 browsing the Monastery: (5)
As of 2015-09-02 02:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My preferred temperature scale is:










    Results (60 votes), past polls