NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.
All the Perl that's Practical to Extract and Report
Stories, comments, journals, and other submissions on use Perl; are Copyright 1998-2006, their respective owners.
splice? (Score:1)
I think this will do it:
Just make sure you use it in list context, though.
-- dagolden
Re: (Score:2)
Lovely!
You don't even need the return:
That is a hack of great beauty. Thanks David :)
Re: (Score:1)
-- dagolden
Re: (Score:2)
Re: (Score:1)
A different solution (Score:1)
This isn’t better, but in the spirit of TMTOWTDI and of the
selectidiom fromperldoc -q unbuffer…Or to do away with the array-copy, assuming you have set up with “
my $log = []” instead:The
\@$construction is there to force Perl to make a new copy of the array reference in$log. That way the first list element is a copy of$loginstead of an alias, and therefore unaffected by the overwritdelete Works Too (Score:1)
You can also do this with
deleteinstead ofsplice:It's slightly slower than
splicebut you may consider it's closer to documenting your intent.Re: (Score:2)
Check out Test::Resub (Score:1)