in reply to Re: what is *undef* ?
in thread what is *undef* ?
actually, noyhcat, the problem with your elegant version is that it makes print act like a function (darn those parentheses, eh beatnik?). there are two easy solutions you don't mention:
orprint ((defined $a) ? "Defined\n" : "Undefined\n");
the first uses another set of parens to pass print the right stuff. the second uses perl's mystifying unary plus. unlike some languages, where unary plus does something useless, like take the absolute value of the argument, perl's unary + serves the important function of being a non-parenthesis. this means that things like warn, print, and my_user_func won't be handed the contents of that set of parens as their sole argument list.print +(defined $a) ? "Defined\n" : "Undefined\n";
isn't that something? unary + is nothing. there's nothing like it; all it does is *be* something.
.update: mmm, yes, japhy smart. vynce not so smart. obvious answer is, like japhy says, to move the parens to just around defined's argument. but i'm still happy to have gotten to explain the useful use of perl's unary +.
.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: what is *undef* ?
by japhy (Canon) on May 25, 2001 at 15:47 UTC |