Dr.Avocado has asked for the wisdom of the Perl Monks concerning the following question:
open(SuitDoc,<STDIN>) || die "Cannot open file"; @suits = ("hearts","clubs","spades","diamonds"); foreach $suit (@suits) { while(my $line = <SuitDoc>) { If($line =~ /($suit)/) { print "$suit"; } } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Searching Line by Line Multiple Times
by Joost (Canon) on Aug 01, 2007 at 19:43 UTC | |
by ikegami (Patriarch) on Aug 02, 2007 at 02:22 UTC | |
|
Re: Searching Line by Line Multiple Times
by Limbic~Region (Chancellor) on Aug 01, 2007 at 23:11 UTC | |
|
Re: Searching Line by Line Multiple Times
by snopal (Pilgrim) on Aug 01, 2007 at 19:48 UTC | |
|
Re: Searching Line by Line Multiple Times
by liverpole (Monsignor) on Aug 02, 2007 at 03:58 UTC | |
|
Re: Searching Line by Line Multiple Times
by graff (Chancellor) on Aug 02, 2007 at 02:16 UTC | |
|
Re: Searching Line by Line Multiple Times
by akho (Hermit) on Aug 02, 2007 at 13:19 UTC |