The following code is what I used to check if item number could be detected for the file I sent in the earlier email. The code seems to have failed and need a advise on it..
A couple of suggestions/corrections:
#!C:\perl\bin\perl5.6.1
use strict; use warnings;
$file1 = ' C:\perl\bin\dummy.txt' ;
open (INFO, "< $file1 ") or die "Can't open $file: $1";
while (<INFO>)
This assigns each line in turn to the special variable $_
{
if ($test = ~ "/2\.2\./d+\./d+\./d+"){
so, matching against $test, which is undefined, does nothing. Also, the regular expression should not be in quotes. What you want to do is match the regular expression againg $_ and capture the data you want using the regular expression capture operator (). Using your above expression that would be something like:
if ( $_ =~ /2\.2\.(/d+)\.(/d+)\.(/d+)/ ){
or since the $_ variable is implied, it can be shortened to:
if ( /2\.2\.(/d+)\.(/d+)\.(/d+)/ ){
print " $test \n " ; }}
Using the above captures, your results will now be in the variables $1, $2, & $3.
close (INFO);
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>