|
Re: [SPOILER] Perl 'Easy' Quiz of the Week #2005-1: msg#00045lang.perl.qotw.discuss
On Mon, Jan 24, 2005 at 01:11:33PM -0500, Daniel Martin wrote: That's a neat approach. > while(<>) { > /^(\w+)\.[A-Z]$/ or die "Bad line: $_"; > if ($prefix ne $1) { > $prefix = $1; > print $mline; > $mline = "$prefix.M\n"; > } if ($mline eq $_) { $mline = ''; } Otherwise you print out an extra "mline" when one already exists. > if ($mline lt $_) { You could change that to if ($mline and $mline lt $_) { to save a lot of unnecessary printing of an empty string. > print $mline; > $mline = ''; > } > print; > } > print $mline; > __END__ Ronald |
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | Re: [SPOILER] Perl 'Easy' Quiz of the Week #2005-1 (Correction): 00045, Daniel Martin |
|---|---|
| Next by Date: | Re: [SPOILER] Perl 'Easy' Quiz of the Week #2005-1: 00045, John Macdonald |
| Previous by Thread: | Re: [SPOILER] Perl 'Easy' Quiz of the Week #2005-1 (Correction)i: 00045, Daniel Martin |
| Next by Thread: | Re: [SPOILER] Perl 'Easy' Quiz of the Week #2005-1: 00045, John Macdonald |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |