more useful options | |
PerlMonks |
Most Efficient Way to match thisby jmneedhamco (Novice) |
on Mar 30, 2015 at 20:40 UTC ( [id://1121898]=perlquestion: print w/replies, xml ) | Need Help?? |
jmneedhamco has asked for the wisdom of the Perl Monks concerning the following question: I am reading in a file whose line looks like this: userid:access_stuff:more_foo... My script needs to match a string in a variable which happens to be a userid and I need to match the userid in the file...first "word" to that first colon. example: userid matches userid so bale. So, basically, the jist is: 1) the following code is my idea (it is paraprhased, because I am not going to actually write the code for opening files, etc here.) 2) I need to figure out the most efficient way to code the idea of: "if line to first colon matches variable".
The linefraq variable would hold just the userid "substring" from the line read from the file. Of course, in practice, each line will be read and checked for the userid. Thank-you for your help!
Back to
Seekers of Perl Wisdom
|
|