Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Perl Misc (http://www.velocityreviews.com/forums/f67-perl-misc.html)
-   -   is there a compact way to initialize this array? (http://www.velocityreviews.com/forums/t911330-is-there-a-compact-way-to-initialize-this-array.html)

DaLoverhino 09-09-2009 06:46 PM

is there a compact way to initialize this array?
 
I want to initialize an array with 100 empty strings.

I can use a loop, but is there a more compact way to do so?

thanks.

Uri Guttman 09-09-2009 06:53 PM

Re: is there a compact way to initialize this array?
 
>>>>> "D" == DaLoverhino <DaLoveRhino@hotmail.com> writes:

D> I want to initialize an array with 100 empty strings.
D> I can use a loop, but is there a more compact way to do so?

my @empty = ('') x 100 ;

and you likely don't need to do that if you are appending text as each
entry will autovivify. .= works cleanly and quietly (no warnings) on
undef values.

uri

--
Uri Guttman ------ uri@stemsystems.com -------- http://www.sysarch.com --
----- Perl Code Review , Architecture, Development, Training, Support ------
--------- Gourmet Hot Cocoa Mix ---- http://bestfriendscocoa.com ---------


All times are GMT. The time now is 12:44 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.