Chris Charley""  wrote in message news
Tim wrote in message news:[email protected]...

I hope this is a simple fix.  I want to check the beginning characters of
items in a hash, and compare that to a scalar variable.
I do not need for the entire value to match; just the first couple of characters.
Tim

[snip]


Hello Tim,

[snip]



I might have approached it differently.


#!/usr/bin/perl
use strict;
use warnings;

my $prefix_search_list = '03S|04S';

while (<DATA>) {
   print if /^$prefix_search_list/;
}

__DATA__
05S885858
03S84844
foo
bar
04Sbaz

A correction to my answer:

print if /^$prefix_search_list/;
should be:

print if /^(?:$prefix_search_list)/;

Chris

--
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
http://learn.perl.org/


Reply via email to