On Monday 08 Mar 2010 18:00:10 Ryan Chan wrote:
> my ($a, $b, $c, $d, $e) = "test";
> 
> How I can assign "test" to all the list items? e.g. $a to $e

First of all, you should not name lexical variables "$a" and "$b" because 
these are built-in Perl variables: http://perldoc.perl.org/perlvar.html . 

Otherwise you can assign several variables the same initial value using the x 
operator:

my ($x, $y, $z) = (("test") x 3);

Note that both pairs of parentheses on the right are required.

That put aside, I should note that assigning several different variables the 
same value smells of code-duplication and varvarname (see 
http://perl.plover.com/varvarname.html ). Please consider using an array or a 
hash instead or code a more well-rounded code.

Regards,

        Shlomi Fish

-- 
-----------------------------------------------------------------
Shlomi Fish       http://www.shlomifish.org/
Optimising Code for Speed - http://shlom.in/optimise

Deletionists delete Wikipedia articles that they consider lame.
Chuck Norris deletes deletionists whom he considers lame.

Please reply to list if it's a mailing list post - http://shlom.in/reply .

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to