in reply to Secret Perl Operators: the boolean list squash operator, x!!
Your x!! approach is nifty, but it's a little hard to read: the double-negation is confusing unless explained, and the x operator seems to be out of place in this context. I have always found one of these easier to read:
my $uri; foreach ( 'http://example.net/app', $is_admin_link && 'admin', $subsite, $mode, $id, $submode, ) { $uri.="$_/" if ( defined $_ && length($_) ) #omit undef and empties }
If you need to preserve the parts seperately:
my @part = ( 'http://example.net/app', $is_admin_link && 'admin', $subsite, $mode, $id, $submode, ); my $uri; foreach (@parts) { $uri.="$_/" if ( defined $_ && length($_) ) #omit undef and empties }
I prefer these because:
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Secret Perl Operators: the boolean list squash operator, x!!
by Aristotle (Chancellor) on Aug 02, 2006 at 14:06 UTC | |
by radiantmatrix (Parson) on Aug 02, 2006 at 14:19 UTC | |
by Aristotle (Chancellor) on Aug 02, 2006 at 15:35 UTC |