Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
Hi Monks!
I working on a code and I have to search for a specific letters code coming from a file, the values I am checking against are: XLX or TLX or XLT or LX.
I am doinf a simple check like this:
I know that this wouldn't work because all the other letter codes has the "LX" in them, that would fail, correct?
I am doing this way:
Is this way the more reliable way to get "LX" by using word boundary or there is a better and more efficient way to do this?
Thanks for the help!
I working on a code and I have to search for a specific letters code coming from a file, the values I am checking against are: XLX or TLX or XLT or LX.
I am doinf a simple check like this:
my $type="LX"; if( $type=~/LX/) { do stuff ... }
I know that this wouldn't work because all the other letter codes has the "LX" in them, that would fail, correct?
I am doing this way:
my $type="LX" if( $type=~/\bLX\b/) { do stuff ... }
Is this way the more reliable way to get "LX" by using word boundary or there is a better and more efficient way to do this?
Thanks for the help!
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Searching for a specific pattern.
by phenom (Chaplain) on Jun 18, 2010 at 19:18 UTC | |
by Anonymous Monk on Jun 18, 2010 at 19:20 UTC | |
by ikegami (Patriarch) on Jun 18, 2010 at 19:50 UTC | |
Re: Searching for a specific pattern.
by almut (Canon) on Jun 18, 2010 at 19:25 UTC |
Back to
Seekers of Perl Wisdom