Same with scalars...
our $s1 = "a";
my %s2 = "b";
our $s3 = "c";
for my $it (qw(s1 s2 s3)){
print "$it: $$it\n";
}
... prints...
Name "main::s1" used only once: possible typo at scalersymref.pl line 2.
Name "main::s3" used only once: possible typo at scalersymref.pl line 4.
Use of uninitialized value in concatenation (.) at scalersymref.pl line 8.
s1: a
s2: # was a my
s3: c
...Locals work...
$s2 = "s";
{
our $s1 = "a";
local $s2 = "b";
our $s3 = "c";
for my $it (qw(s1 s2 s3)){
print "$it: $$it\n";
}
}
... prints...
Name "main::s1" used only once: possible typo at scalersymref.pl line 4.
Name "main::s3" used only once: possible typo at scalersymref.pl line 6.
s1: a
s2: b ### not "s"
s3: c
See perlref 'Symbolic References' or Camel 2 section 4.4, on 'Symbolic
References':
-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]]On Behalf Of
Peter Eisengrein
Sent: Thursday, June 14, 2001 1:44 PM
To: Perl-Win32-Users Mailing List (E-mail)
Subject: @$_ works, so why doesn't %$_ ?
Aaarggghhhhh. This is making me nutty! I have several hashes that I want to
process identically, so I put their names in an array and want to call those
names iteratively from the array. But I just can't get it to work. Please
help!
### here's what I am trying to do:
my @list = ("hash_one","hash_two","hash_three");
foreach (@list)
{
### now process %$_ which I want to be
### %hash_one
### then %hash_two
### then %hash_three
}
I've used @$_ before, so why doesn't %$_ work? I've tried...
%$_
%{$_}
%${_}
%{${_}}
%\$_
%(eval($_))
... and every other combination I can think of. I'll just be here banging my
head on my desk........
Thanks group.
_______________________________________________
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users
_______________________________________________
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users