Re: Shortening the ?: construct
- From: Peter@xxxxxxxx (Peter Scott)
- Date: 18 Apr 2009 10:29:33 -0000
On Fri, 17 Apr 2009 22:02:37 -0500, Chap Harrison wrote:
[...]
my $foo = ( defined $very_long_expression ? $very_long_expression :
"n/a" );
At some point I thought I read about a shorter way to write this, that
did not involve repeating the $very_long_expression in the same
statement. Perhaps a special variable or something, acting sort of like
a pronoun. Anyone know of a shortcut?
Thanks,
Chap Harrison
Perl 5.8.8
Well, if you're able to upgrade to 5.10:
my $foo = $very_long_expression // "n/a";
--
Peter Scott
http://www.perlmedic.com/
http://www.perldebugged.com/
http://www.informit.com/store/product.aspx?isbn=0137001274
.
- Follow-Ups:
- Re: Shortening the ?: construct
- From: Chap Harrison
- Re: Shortening the ?: construct
- References:
- Shortening the ?: construct
- From: Chap Harrison
- Shortening the ?: construct
- Prev by Date: Strip email attachments using IMAP.
- Next by Date: Re: Data Comparison
- Previous by thread: Re: Shortening the ?: construct
- Next by thread: Re: Shortening the ?: construct
- Index(es):
Relevant Pages
|