ajt has asked for the wisdom of the Perl Monks concerning the following question:
Thus you can do:
instead of the more obvious, though slower:if (-e $file && -T _) { print "foo"; }
if (-e $file && -T $file) { print "bar"; }
I was quite inpressed with this, indeed it's mentioned again in chapter 24. I tried some tests this morning, and using the underscore is quite a bit faster on my Wintel box, than separate tests.
I've never seen this construct before, though it's easy enough to miss, and even though I've seen it now it's hard to search for an underscrore like this, as underscore is used in some many other places.
Q1 Does anybody actually use this construct? I don't recall seeing it in any books, though I've just this minute found it in the excellent Effective Perl Programming
Q2 What other little tricks like this have I missed? I know there are many things I must have missed, so this question is like asking how long is a piece of string, but what are peoples favourite coding constructs that are "cool" but uncommon
As ever, thanks in advance...
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Does anyone use underscore pseudo-filehandle?
by rob_au (Abbot) on Sep 30, 2001 at 16:51 UTC | |
|
Re: Does anyone use underscore pseudo-filehandle?
by merlyn (Sage) on Sep 30, 2001 at 19:00 UTC | |
|
Re: Does anyone use underscore pseudo-filehandle?
by demerphq (Chancellor) on Sep 30, 2001 at 18:35 UTC | |
|
Re: Does anyone use underscore pseudo-filehandle?
by blakem (Monsignor) on Sep 30, 2001 at 16:55 UTC | |
|
Re: Does anyone use underscore pseudo-filehandle?
by Rudif (Hermit) on Oct 01, 2001 at 02:49 UTC |