gmoque has asked for the wisdom of the Perl Monks concerning the following question:
Does anyone can see what is wrong with this code?, I am looking how to make an OO module but I am having trouble passing arguments in a hash form like this:
The concrete problem is the code below, I am expecting to print "one" but I get an error.mySub( opt1 => $value1 opt2 => $value2 opt3 => $value3 )
#!/usr/bin/perl use strict; hash( uno => 'one', dos => 'two', tres => 'three', ); sub hash { my $param = @_; print $param->{uno}, "\n"; }
When I execute that code I get the following error:
Thanks~/programming/perl/oo$ ./test.pl Can't use string ("6") as a HASH ref while "strict refs" in use at ./t +est.pl line 7.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: hash ref 101
by moritz (Cardinal) on Dec 17, 2008 at 09:03 UTC | |
|
Re: hash ref 101
by lakshmananindia (Chaplain) on Dec 17, 2008 at 11:24 UTC | |
by eleron (Novice) on Dec 17, 2008 at 11:35 UTC | |
|
Re: hash ref 101
by DStaal (Chaplain) on Dec 17, 2008 at 13:57 UTC | |
by AnomalousMonk (Archbishop) on Dec 17, 2008 at 14:41 UTC | |
by gmoque (Acolyte) on Dec 18, 2008 at 01:59 UTC | |
|
Re: hash ref 101
by matrixmadhan (Beadle) on Dec 17, 2008 at 10:30 UTC |