mosh has asked for the wisdom of the Perl Monks concerning the following question:
I've got impossible error from Perl:
"Can't use string ("string") as a HASH ref while "strict refs" in use at C:\... line 1190"
What the heck should be this error ?
I searched the Web, and here what I got:
code 1:
#!/usr/bin/perl -w use strict; sub showArray(\@) { my(@arr) = @{(shift)}; my($temp); foreach $temp (@arr) { print "$temp\n"; } } sub higherLevel(\@) { my(@arr) = @{(shift)}; showArray(@arr); } my(@arr) = ("one","two","three"); higherLevel(@arr);
Code 2:
#!/usr/bin/perl -w use strict; sub higherLevel(\@) { my(@arr) = @{(shift)}; showArray(@arr); } sub showArray(\@) { my(@arr) = @{(shift)}; my($temp); foreach $temp (@arr) { print "$temp\n"; } } my(@arr) = ("one","two","three"); higherLevel(@arr);
The first code went great, but the second returned the previous error !
I do not understand, the two sections are the same !!!
What the heck is going on?
Mosh.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: a HASH ref while "strict refs" ERROR
by ikegami (Patriarch) on May 04, 2005 at 17:34 UTC | |
by Roy Johnson (Monsignor) on May 04, 2005 at 17:57 UTC | |
by ikegami (Patriarch) on May 04, 2005 at 19:27 UTC | |
|
Re: a HASH ref while "strict refs" ERROR
by Paladin (Vicar) on May 04, 2005 at 17:39 UTC |