[oclug] Simple/Stupid Perl Q

Jon Earle je_oclug at kronos.honk.org
Wed Nov 5 11:55:53 EST 2003


On Wed, 5 Nov 2003, Joe Burpee wrote:

> On Wed, Nov 05, 2003 at 10:53:23 -0500, Jon Earle wrote:
> > my ($str1, $str2, $str3, $str4) = '';
> >
> > Which I realized this AM was only initializing the first value, as the LHS
> > was taken to be a list (and the RHS to be a single scalar).  So, unless I
> > write it like:
> >
> > my ($str1, $str2, $str3, $str4) = ('', '', '', '');
> >
> > is there any other way to rapidly init a number of vars to the same value?
>
>   my ($str1, $str2, $str3, $str4) = ('')x4;
>
> or if you're too lazy to count  8-)
>
>   my ($str1, $str2, $str3, $str4) = ('')x99;

Thanks Joe, that did the trick.


-- 
Jon Earle

SAVE FARSCAPE http://www.savefarscape.com/

Vegetarian - an old Indian word meaning 'lousy hunter'.



More information about the OCLUG mailing list