|
Re: [SPOILER] Perl 'Easy' Quiz of the Week #2005-1 (Correction): msg#00044lang.perl.qotw.discuss
On Mon, 24 Jan 2005, Daniel Martin wrote: Huh. No one so far seems to have hit upon the solution I hit upon, which was: (I've deliberately left out most error checking since I want the main script body uncluttered) And wouldn't you know it, I left out a piece. Here's a corrected script: #!/usr/bin/perl use strict; open(STDIN, '<', shift) if @ARGV; open(STDOUT, '>', shift) if @ARGV; my $mline=''; my $prefix=''; while(<>) { /^(\w+)\.[A-Z]$/ or die "Bad line: $_"; if ($prefix ne $1) { $prefix = $1; print $mline; $mline = "$prefix.M\n"; } if ($mline lt $_) { print $mline; $mline = ''; } elsif ($mline eq $_) { $mline=''; } print; } print $mline; __END__ |
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | [SPOILER] Perl 'Easy' Quiz of the Week #2005-1: 00044, Daniel Martin |
|---|---|
| Next by Date: | Re: [SPOILER] Perl 'Easy' Quiz of the Week #2005-1: 00044, Ronald J Kimball |
| Previous by Thread: | [SPOILER] Perl 'Easy' Quiz of the Week #2005-1i: 00044, Daniel Martin |
| Next by Thread: | Re: [SPOILER] Perl 'Easy' Quiz of the Week #2005-1: 00044, Ronald J Kimball |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |