[oak perl] Perl for physical security :-)
David Alban
extasia at mindspring.com
Wed Dec 4 18:33:02 CST 2002
Belden,
At 2002/12/04/16:18 -0800 Belden Lyman <blyman at iii.com> wrote:
> my $codes = [ map { chr $_ } 33..126 ];
>
> Later, you can eliminate your call to chr(). This
> way you just comput the chr of each @$codes member
> just once, rather than each time you print it.
Awesome! Good catch. Done! New version is faster. :-)
> Incidentally, why use an array ref?
>
> print $codes[ int rand @codes ];
>
> vs
>
> print $$codes[ int rand @$codes ];
That's a good question. I'm not sure. I've done a lot of stuff
where I need to pass data structures around, where the use of
references is indicated. I guess I've just gotten into the habit of
using them even when I don't have to.
They're probably more inefficient if you don't need them. One more
level of indirection and all that...
*extasia makes mental note for future performance tuning
David
P.S. "obfuscate" is *really* effective when I print the output twice
per side on the sheet of paper. :-)
--
Live in a world of your own, but always welcome visitors.
***
Come to sig-beer-west! http://www.gerasimov.net/~alban/sig.beer.west.html
Unix sysadmin available: http://www.gerasimov.net/~alban/jac/resume.html
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 232 bytes
Desc: not available
Url : http://mail.pm.org/pipermail/oakland/attachments/20021204/6be37f26/attachment.bin
More information about the Oakland
mailing list