in reply to using join with a print ref statement
I originally wrote this for Bismark at http://www.greentechnologist.org/wiki/wiki?Bismark which was a quick fix-up of some pre-existing code currently viewable on Bismark's scratchpad (I've asked Bismark to post the code in response to this so the context can be retained). The idea was print TRIGRAPH or just a fancy if/else.
I didn't use a if/else because it's clearer this way that you're just switching between strings to print. A if/else construct would have to have two calls to print() which violates my sense of aesthetics. That ref() function is controlling the "? :" construct. So ref $searchresult is the test. The true answer comes immediately after the '?' character and then false answer comes immediately after the : character. You can't swap them though - test : true ? false is invalid. It's always test ? true : false.
if (ref $searchresult) { print "Found it: @$searchresult\n"; } else { print "It wasn't found\n"; }
Seeking Green geeks in Minnesota
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: using join with a print ref statement
by Bismark (Scribe) on Jan 20, 2003 at 18:38 UTC | |
by diotalevi (Canon) on Jan 20, 2003 at 18:57 UTC | |
by Bismark (Scribe) on Jan 20, 2003 at 19:46 UTC | |
by diotalevi (Canon) on Jan 20, 2003 at 21:13 UTC |