On Dec 11, 2008, at 11:39 AM, Brian Raven wrote:

From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of
[EMAIL PROTECTED]
Sent: 11 December 2008 16:29
To: [email protected]
Subject: Initializing list of variables

> Gurus,
>
> I'm almost ashamed to have to post this, because I know this is a
newbie question, and I'm not really one of
> those any more, but I'm drawing a blank.  Isn't there an easier way to
initialize a list of variables, to a
> common value, than this:
>
> my ($a, $b, $c, $d, $e, $f) = ('init', 'init', 'init', 'init', 'init',
'init');

I'm not sure how I would do it with map, but the following is likely to
be simpler.

my ($a, $b, $c, $d, $e, $f) = ('init') x 6;

See 'Multiplicative Operators' in 'perldoc perlop' for more details.

>
> I'm *sure* I've seen this done using map, but, like I said, every trip
to the well yields an empty bucket--
> except for the no-brainer line above.
>
> TIA, and PLEASE try not to laugh too loud...

No more than a gentle chuckle. Promise.

HTH

--  
Brian Raven

This one also works - TMTOWTDI

my ($a,$b,$c) = map { 'init' } 1..3;

Phil Rafferty

-----------------------------------------------------------------------------------------------------------
This e-mail may contain confidential and/or privileged information. If  
you are not the intended recipient or have received this e-mail in  
error, please advise the sender immediately by reply e-mail and delete  
this message and any attachments without retaining a copy. Any  
unauthorised copying, disclosure or distribution of the material in  
this e-mail is strictly forbidden.


_______________________________________________
ActivePerl mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

_______________________________________________
ActivePerl mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to