in reply to Re: Re: Re: Reducing repetitive code
in thread Reducing repetitive code
Hmm, all of those could be solved by doing proper input validation. Also, for your second point, just indexing the array doesn't grow it, at least not on my version of perl:
$ perl -MDevel::Size -e '@a = (0 .. 11); print Devel::Size::total_size +(\@a)' 296 $ perl -MDevel::Size -e '@a = (0 .. 11); $i = $a[56788]; print Devel:: +Size::total_size(\@a)' 296 # Just to make sure perl doesn't optimize away the assignment $ perl -MO=Deparse -MDevel::Size -e '@a = (0 .. 11); $i = $a[56788]; p +rint Devel::Size::total_size(\@a)' -e syntax OK use Devel::Size; @a = (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11); $i = $a[56788]; print Devel::Size::total_size(\@a); $ perl -v This is perl, v5.8.0 built for MSWin32-x86-multi-thread (with 1 registered patch, see perl -V for more detail) Copyright 1987-2002, Larry Wall Binary build 806 provided by ActiveState Corp. http://www.ActiveState. +com Built 00:45:44 Mar 31 2003 # snip the rest
What would grow the array is autovivification, such as if you said $i = $a[57874]{key};.
----
I wanted to explore how Perl's closures can be manipulated, and ended up creating an object system by accident.
-- Schemer
: () { :|:& };:
Note: All code is untested, unless otherwise stated
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re^4: Reducing repetitive code
by duff (Parson) on Jan 06, 2004 at 20:37 UTC | |
|
Re: Re^4: Reducing repetitive code
by dragonchild (Archbishop) on Jan 06, 2004 at 20:17 UTC |