NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.
All the Perl that's Practical to Extract and Report
Stories, comments, journals, and other submissions on use Perl; are Copyright 1998-2006, their respective owners.
The pumpking advice (Score:2)
Re: (Score:1)
Just what I wrote in original post : ($x =? expr) would mean
($tmp = expr and $x = $tmp)
> What would "$x = $y =? $z" do ?
$x = ($tmp = $z and $y = $tmp)
so if $z is false, $y is untouched and $x is false, whereas with
"$x =? $y =? $z"
both $x and $y stay untouched if $z is false
Easily done already. (Score:1)
Re: (Score:1)
> eval { $some_hash{some_key} = ( expr or die ) };this would catch exceptions raised in
expr.> $_ = expr or $_ for $some_hash{some_key};well, not many readers would quickly guess that we are assigning something in the hash here
Re: (Score:1)
My suggestions were actually tongue-in-cheek, particularly the
eval-based one. I would never write code like that.But it occurs to me that you can just as well arrange the aliasing in #2 the other way around:
$_ and $foo{bar} = $_ for $baz;
Unlike my previous suggestion this also avoids the unnecessary assignment in case the expression is false. I might actually use this in real code, although I would probably not write it with
ifand aforconstruct rather than theformodifier.for ( expr ) { $foo{ba
Luckily... (Score:1)
sub update { $_[0] = $_[1] if $_[1]; $_[1] }