http://www.perlmonks.org?node_id=407265

nightfreightpilot has asked for the wisdom of the Perl Monks concerning the following question:

1st..excellent site. I have only tonight stumbled upon what appears to be the plethora of perl information I have been searching for. I am late in life starting my programming journey, however there is no time like the present to start. Perl is my first language and the learning curve seems steep indeed. I am self-teaching using both the Sam's 24 book and the "Camel" book. I am in the first chapters.

With the assistance of Cingular, and cut/paste, I have created a file of all the phone numbers I've called. With my first real code, I would like to open that file and simply identify how many times I've called a particular number. Adding the minutes and such will come at a later time I suppose. I printed the file and manually determined the number of times I have called a number ending with 9432 to be 84 out of nearly 300 entries (for error checking purposes). The code I have written thus far follows:

open (CINGULAR, "c:/documents and Settings/david price/my documents/cingular.txt") || die "cannot open: $!"; @number=<CINGULAR>; close (CINGULAR); $count=0; while ($count<100) { if (@number=~[/^9432$/g]) { print "match found"; } else { print "match failed"; } $count++; }

Upon running, I receive the following errors:

Applying pattern match (m//) to @array will act on scalar (@array)at cingular.pl line 9....and Use of uninitialized value in pattern match +(m//) at cingular.pl line 9.

Obviously my code isn't running, but I'm not sure as to why. I've bound using ~...am looking from beginning to end of line for 9432....each time I look through a line the count in incrementing. Any help would be most welcome.

Thank you.

Edited by davido: Rescued formatting, supplied code tags.