in reply to help manipulating data in an array.

Try this:

open (CINGULAR, "c:/documents and Settings/david price/my documents/ci +ngular.txt") || die "cannot open: $!"; @number=<CINGULAR>; close (CINGULAR); # Remove the following commented lines # $count=0; # while ($count<100) { # if (@number=~/^9432$/g) { # print "match found"; } # else { # print "match failed"; # } # $count++; # } # and change them to: foreach $line ( @number ) { if ( $line =~ /^9432$/g ) { print "Match found\n"; } else { print "Match failed\n"; } }

The foreach loop allows you to loop through each element of the array, pull out one element at a time ($line), check it for the pattern, and print the appropriate message. You could add a counter in one or both sections of the conditional block to determine the number of matches/non-matches you get and print this as a summary at the end of the script. ( Beats manually counting up the "Match Found" and "Match Failed" lines in the DOS window. :) )

You're going to want to rethink your regular expression, though. :) Think about what the ^ and $ anchors are do. The way you have it written right now, you will only get a match when the number 9432 is the only text in the line.

HTH,

/Larry