> Hi all, I'm trying to figure out how can I check if a variable matches
the
> first 5 digits of the line below without removing anything from the line.
>
> 13384 R 20020920 N Gatekeeper, The
>
> Silver Fox
>
I'm a bit confused, are you trying to test the line against a variable
or a variable against the line? Oh that helped didn't it ;-)....
my $variable = 13384;
my $line = '13384 R 20020920 N Gatekeeper, The';
if ($line =~ /^$variable/) {
# line starts with variable
}
- or -
if ($variable eq substr($line, 0, 5)) {
# variable equals first 5 characters of line
}
http://danconia.org
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>