Hi  all

In the program below I am attempting to count the number of times that a phone 
number(purely digits) occurs in a file of text. 
I am not succeeding cause i end up counting all the digits of phone numbers that 
occurs.

Could anyone help.

----------------------------------------------------------------------------------------------------------
dat.txt
0216339509 is my phone number 0216339509 also belong to
my brother 0216339509 and 0216339509 from sister.
---------------------------------------------------------------------------------------------------------

Program:

#!/usr/bin/perl -w
my $match_cntr = 0;
my $n = 0;

open(FILE,"<dat.txt");
my @file_array = <FILE> ;
for($n=0;$n<=$#file_array;$n++) {
        while($file_array[$n]=~/(\d)/gxom){
                print $1;
                $match_cntr++;
        }
}#end of for loop
print "NUMBERS COUNTED = ",$match_cntr,"\n";
close(FILE);


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to