in reply to eliding number ranges
#!/usr/bin/perl use strict; use warnings; while (<DATA>) { chomp; my ($f, $s) = split; unless (length ($f) == length ($s)) { print "$f-$s\n"; next; } if ($f == $s) { print $f, "\n"; next; } print "$f-", substr ($s => length +(("$f" ^ "$s") =~ /^(\x00*)/) [ +0]), "\n"; } __DATA__ 1 32 4 19 28 39 34 123 321 321 324 329 325 349 340 509
Abigail
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Golf: eliding number ranges
by Roy Johnson (Monsignor) on Nov 14, 2003 at 16:28 UTC | |
|
Re: Re: eliding number ranges
by Anonymous Monk on Nov 13, 2003 at 15:41 UTC | |
by antirice (Priest) on Nov 13, 2003 at 17:14 UTC | |
by Roy Johnson (Monsignor) on Nov 13, 2003 at 17:08 UTC | |
by EdwardG (Vicar) on Nov 13, 2003 at 18:24 UTC |