REQ: Help with hash reference to a module
From: Joe (joeblow_at_joes.com)
Date: 01/29/05
- Next message: ioneabu_at_yahoo.com: "Re: REQ: Help with hash reference to a module"
- Previous message: Kjetil Skotheim: "Re: remove junk characters"
- Next in thread: ioneabu_at_yahoo.com: "Re: REQ: Help with hash reference to a module"
- Reply: ioneabu_at_yahoo.com: "Re: REQ: Help with hash reference to a module"
- Reply: Sherm Pendley: "Re: REQ: Help with hash reference to a module"
- Reply: Chris Mattern: "Re: REQ: Help with hash reference to a module"
- Reply: Bill Smith: "Re: Help with hash reference to a module"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sat, 29 Jan 2005 21:12:48 GMT
Hello all,
Old C programmer here. Trying to pass a reference to a hash to a sub
routine in a module.
Have seen many posts about references, nothing seems to work in the case
of modules.
The following example currently returns the error:
Type of arg 3 to MYSTUFF::ParseAssociative must be hash (not reference
construct
or) at main.pl line 9, near "%myListeners )"
Execution of main.pl aborted due to compilation errors.
I would like it to say:
L= adam, hello0
L= Nothing, hello1
L= Something, hello2
Here are the two files:
test.pl
------------------------------------------------
use MYSTUFF;
my %myListeners;
my $test1 = "Nothing";
my $test2 = "Something";
$myListeners{"adam"} = "Hello0";
MYSTUFF::myWorst( $test1, $test2, \%myListeners );
foreach $listener (sort(keys %myListeners)) {
print "L= $listener, $myListeners{$listener}\n";
}
exit;
------------------------------------------------
MYSTUFF.pm
------------------------------------------------
package MYSTUFF;
sub myWorst ($$\%) {
my ($first, $second, %refArray) = @_;
$refArray{$first} = "hello1";
$refArray{$second} = "hello2";
}
1;
--------------------------------------------------
help, and example are greatly appreciated,thanks.
btw perl5.8
- Next message: ioneabu_at_yahoo.com: "Re: REQ: Help with hash reference to a module"
- Previous message: Kjetil Skotheim: "Re: remove junk characters"
- Next in thread: ioneabu_at_yahoo.com: "Re: REQ: Help with hash reference to a module"
- Reply: ioneabu_at_yahoo.com: "Re: REQ: Help with hash reference to a module"
- Reply: Sherm Pendley: "Re: REQ: Help with hash reference to a module"
- Reply: Chris Mattern: "Re: REQ: Help with hash reference to a module"
- Reply: Bill Smith: "Re: Help with hash reference to a module"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|
|