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

statement modifiers for setting variables

Thread Next
From:
Dave Whipp
Date:
April 18, 2005 18:01
Subject:
statement modifiers for setting variables
Message ID:
20050419010148.25328.qmail@lists.develooper.com
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


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About