In a message dated 3/9/2004 2:43:16 PM Eastern Standard Time, [EMAIL PROTECTED] writes: >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
use strict; use warnings; my $line = "13384 R 20020920 N Gatekeeper, The"; my $var = 13384; my ($match) = ($line =~ /(\d{5})/); print "Match! ", $var,"==", $match,"\n" if $var == $match; #OR my $substr = substr $line, 0, 5; print "Match! ",$var,"==",$substr,"\n" if $var == $substr; #Is the line the same? print $line,"\n"; -will (the above message is double rot13 encoded for security reasons) Most Useful Perl Modules -strict -warnings -Devel::DProf -Benchmark -B::Deparse -Data::Dumper -Clone (a Godsend) -Perl::Tidy -Beautifier -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>