Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
I want to isolate the line containing apple. But when I uses the following code to print the line containing apple.TEXAS,apple,2,E,0,0000, 0030, 0145, 0030, 0145, 0100, + 0030, 0145, 0000, 0000, 3 NEVADA,GRAPE,2,E,0,0000, 0030, 0145, 0030, 0145, 0100, + 0030, 0145, 0000, 0000, 3 MONTANA,PEAR,2,E,0,0000, 0030, 0145, 0030, 0145, 0100, + 0030, 0145, 0000, 0000, 3
But instead of only printing the line containing 'apple'. It prints out the entire file. How do I make it print only the line containing apple. - Thanku$fruit = "apple"; if ( $_ =~ /$fruit/) { print "$_"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: print line containing string
by toolic (Bishop) on May 05, 2010 at 16:39 UTC | |
|
Re: print line containing string
by moritz (Cardinal) on May 05, 2010 at 16:36 UTC | |
|
Re: print line containing string
by ChiefAl (Initiate) on May 05, 2010 at 16:59 UTC | |
by Anonymous Monk on May 06, 2010 at 14:12 UTC | |
by Anonymous Monk on May 06, 2010 at 16:05 UTC |