Gunnar Hjalmarsson wrote:
John W. Krahn wrote:
Could you please explain how the code I posted does not accomplish the
OP's objectives or is inefficient?
Well, to me it seems like the pre-defined sentences, including the
undesired newline symbols, are not part of the data that is read by the
while loop. This code illustrates my interpretation of the OP's problem:
my %sentences = (
first => "This is the first sentence.\n",
second => "This is the second sentence.\n",
third => "This is the third sentence.\n",
fourth => "This is the fourth sentence.\n",
);
my @output;
while (<DATA>) {
chomp;
push @output, $sentences{$_} if $sentences{$_};
}
chomp @output;
print "@output\n";
__DATA__
first
second
fourth
OK, I'll concede that I may have misread or not understood the OP's
objectives correctly. :-)
John
--
Perl isn't a toolbox, but a small machine shop where you
can special-order certain sorts of tools at low cost and
in short order. -- Larry Wall
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/