Silverfox wrote:
>
> Hi all,
Hello,
> 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
In perl, if a variable looks like a number then perl will treat it as a
number, so:
my $line = '13384 R 20020920 N Gatekeeper, The';
if ( $line == 13384 ) {
print "The line matched\n";
}
However if you just want only the first five digits:
my ($number) = $line =~ /^(\d{5})/;
That will skip any numbers that are less than five digits long.
John
--
use Perl;
program
fulfillment
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>