----- Original Message ----- From: "Naser Ali" <[EMAIL PROTECTED]> Newsgroups: perl.beginners To: <[EMAIL PROTECTED]> Sent: Monday, June 21, 2004 3:52 PM Subject: Pattern match
> Hello, > > I have an array which was created by slurrping a whole text file. There are > certain element in the array after reading the files which contain only one > word. I want to only match those array elements which contain a single word > and print it. Tried every thing but in vain. I must be doing something > wrong, can any one please suggest the right way of doing this. > > Thanks Hi Naser, This can be done without slurping the file into an array first with the following: open IN, "<", $myfile or die $!; print grep /^\S+$/, <IN>; If you still need to slurp into an array first, the statement above is changed to: print grep /^\S+$/, @array; See perldoc -f grep Chris -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>