in reply to Array: inserting what isn't there
At the risk of it being such, I'll answer anyway.
I'd copy the array into a new array, picking out the initial number of each item, but inserting any items that weren't there.
my @newarray; for (@array) { my ($prefix) = /^(\d+)/ or die "Missing leading integer in $_\n"; ## generate missing elements based on length of @newarray: push @newarray, (@newarray + 1) . ".lost" while @newarray < $prefix - 1; push @newarray, $_; } @array = @newarray; # copy the results back
-- Randal L. Schwartz, Perl hacker
Be sure to read my standard disclaimer if this is a reply.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Array: inserting what isn't there
by Petras (Friar) on May 31, 2003 at 14:58 UTC | |
by merlyn (Sage) on May 31, 2003 at 16:31 UTC | |
by Petras (Friar) on Jun 01, 2003 at 04:57 UTC |