SPUG: Array Naming Question
Brian Maddux
brianmaddux at yahoo.com
Wed Feb 4 09:33:17 CST 2004
Here's a quick program I used to test what I think you
are asking for:
-------
#!/usr/bin/perl -w
@test_array = (1,2,3,4,5);
@other_test_array = (9,8,7,6,5,4,3,2,1);
print "Normal: ".join(",", @test_array)."\n";
$array_name = "test_array";
print "By Name ($array_name): ".join(",",
@{$array_name})."\n";
$array_name = "other_test_array";
print "By Name ($array_name): ".join(",",
@{$array_name})."\n";
-------
And here's the output:
$ /usr/bin/perl test.pl
Name "main::other_test_array" used only once: possible
typo at test.pl line 4.
Normal: 1,2,3,4,5
By Name (test_array): 1,2,3,4,5
By Name (other_test_array): 9,8,7,6,5,4,3,2,1
I hope this answers your question.
Brian Maddux
--- "North, Walter" <wnorth at state.mt.us> wrote:
>
> Good Morning all,
>
> Maybe this is a dumb question, but here goes anyway:
>
> Does anyone know if it possible to include a
> variable in, or use a variable
> as
> the name of an array or hash, and if so how would
> one do it?
>
> thanks in advance.
>
>
>
-----------------------------------------------------
>
> Walter North 406-444-2914
> Operating Systems Programmer
> wnorth (at) state (dot) mt (dot) us
>
-----------------------------------------------------
>
>
>
_____________________________________________________________
> Seattle Perl Users Group Mailing List
> POST TO: spug-list at mail.pm.org
> http://spugwiki.perlocity.org
> ACCOUNT CONFIG:
> http://mail.pm.org/mailman/listinfo/spug-list
> MEETINGS: 3rd Tuesdays, U-District, Seattle WA
> WEB PAGE: http://www.seattleperl.org
>
=====
-------------------------------------------------------
Brian Maddux Whidbey Island, WA
brianmaddux at yahoo.com
-------------------------------------------------------
__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free web site building tool. Try it!
http://webhosting.yahoo.com/ps/sb/
More information about the spug-list
mailing list