develooper Front page | perl.perl6.language | Postings from April 2005

statement modifiers for setting variables

Thread Next
Dave Whipp
April 18, 2005 18:01
statement modifiers for setting variables
Message ID:
The following is legal perl:

   print "$a $b $c" if ($a,$b,$c)=(1,2,3);

This prints "1 2 3", but the definitions obviously aren't scoped to the 
modified statement. And a C<my> in the modifier is a bit too late.

Any reason to [not] add a C<where> statement modifier which restricts 
the scope of the declarations? Sure its redundant, but so are all 
statement modifiers. Sometimes its good to factor things out and express 
them later, rather than earlier. It lets us focus on the important 
things first:

   print "$a $b $c" where ($a,$b,$c)=(1,2,3);

(in this case, we could use printf to to the factoring, but that's not a 
general solution).

Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About