in reply to Re: Re (tilly) 3: References
in thread References
The first breaks all sorts of scoping suggestions by using a lexical global within a tiny function, then using a scoped global right after! Do not do this!! Whenever I see this kind of crap in some program I've been asked to maintain, I rip it out immediately. Of course, it usually takes me an hour or so to do this, just because I can never be sure that there aren't dependencies elsewhere.
The second is a back-asswards way of dereferencing a hashref that would confuse the heck out of me, and anyone else who would read your code. I can read it now, but only because I have some context within which to read it. Again, if I ever saw this in some code I was maintaining, I would rip it out in a heartbeat!
"What should I do?" you ask? Do the following:
And get used to it! This is the way people will write code for you to maintain. You will read this syntax.sub c { my $d = shift; $d->{$_} = $_ foreach (0 .. 200); }
In addition, if you're freaking out about which is faster, I decided to run your Benchmark script, adding in my subroutine. Just for kicks. Here're the results I got:
Pretty interesting, huh?b: 154 wallclock secs (153.27 usr + 0.00 sys = 153.27 CPU) @ 1216.55/s + (n=100000) c: 152 wallclock secs (153.17 usr + 0.00 sys = 153.17 CPU) @ 1216.55/s + (n=100000) f: 156 wallclock secs (156.57 usr + 0.00 sys = 156.57 CPU) @ 1252.98/s + (n=100000)
------
/me wants to be the brightest bulb in the chandelier!
Vote paco for President!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Listen to Tilly ... he knows what's what!
by Cine (Friar) on Aug 20, 2001 at 17:46 UTC | |
by dragonchild (Archbishop) on Aug 20, 2001 at 18:09 UTC | |
by Cine (Friar) on Aug 20, 2001 at 18:19 UTC | |
by dragonchild (Archbishop) on Aug 20, 2001 at 18:37 UTC | |
by Cine (Friar) on Aug 20, 2001 at 18:47 UTC | |
|