User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the Perl section within the Software Development category of DaniWeb, a massive community of 427,730 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,905 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Perl advertiser: Programming Forums

Can Array Name have Variable?

Join Date: Mar 2008
Posts: 17
Reputation: godevars is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
godevars's Avatar
godevars godevars is offline Offline
Newbie Poster

Re: Can Array Name have Variable?

  #4  
Apr 17th, 2008
Thanks katharnakh.
I am running into an issue with using the strict pragma. I 'Use strict' to start and define my arrays as:

my (@array1, @array2, @array3, @array4);

I am using strict since this is only a portion of my code.
The error I receive is 'Global symbol at "@array1" requires explicit package name.' I have:

foreach (1..4){
	push @{"a$_"}, $value;
}

I tried a few things but kept getting the same error. A few are tried:
.
foreach (1..4){
	push my(@{"a$_"}), $value;
}
or
foreach (1..4){
                my (@array1, @array2, @array3, @array4);
	push @{"a$_"}, $value;
}

I wanted to keep the strict pragma on. I did turn it off and it worked. Will that give me other issues down the road? I know when posting code, 'use strict' and 'use warnings' is important.
Thanks-

Thanks again-
Last edited by godevars : Apr 17th, 2008 at 10:34 am.
Reply With Quote  
All times are GMT -4. The time now is 12:26 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC