my ($var1, $var2, $var3) = (1) x 3;

Now that is neat! This usage of the repetition operator (x) is actually described in 'The Camel' book, p. 94


Alfred

Peter Scott wrote:

On Fri, 11 Mar 2005 16:20:50 -0500, Peter Rabbitson wrote:


On Fri, Mar 11, 2005 at 04:09:12PM -0500, Todd W wrote:


"Peter Rabbitson" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]


On Fri, Mar 11, 2005 at 12:45:10PM -0800, Wagner, David --- Senior


Programmer Analyst --- WGO wrote:


Peter Rabbitson wrote:


Is there a quick way to initialize a number of variables at once?
Something like

my ($var1, $var2, $var3);


my ($var1, $var2, $var3) = ( 1,1,1 );


[snip]


What I meant however was something along the lines of my ($var1, $var2, $var3... arbitrary number of vars) = 1, which obviously doesn't work, but I hoped it's only due to my lack of syntax knowledge.



my ($var1, $var2, $var3) = (1) x 3;




--
Perl - "... making the easy jobs easy,
without making the hard jobs impossible."
'The Camel', 3ed



-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>




Reply via email to