Silverfox wrote:

> 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

if you are only concern about digits in front of the line, you don't even 
need a regex. just compare them with '==':

#!/usr/bin/perl
use strict;
use warnings;
no warnings 'numeric';

my $var  = 3384;
my $line = "3384 R 20020920 N Gatekeeper, The";

if($line == $var){
        print "match\n";
}else{
        print "not match\n";
}

__END__

prints:

match

it will fail for the number 0

david
-- 
s$s*$+/<tgmecJ"ntgR"tgjvqpC"vuwL$;$;=qq$
\x24\x5f\x3d\x72\x65\x76\x65\x72\x73\x65
\x24\x5f\x3b\x73\x2f\x2e\x2f\x63\x68\x72
\x28\x6f\x72\x64\x28\x24\x26\x29\x2d\x32
\x29\x2f\x67\x65\x3b\x70\x72\x69\x6e\x74
\x22\x24\x5f\x5c\x6e\x22\x3b\x3b$;eval$;

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to