cowgirl has asked for the wisdom of the Perl Monks concerning the following question:
Here is the module example:#!/usr/bin/perl use Y; use strict; my %hash_to_send; $hash_to_send{first_colour} = "red"; $hash_to_send{second_colour} = "white"; $hash_to_send{third_colour} = "blue"; return &Y::module_subroutine($hash_to_send);
However, it doesn't seem to get the hash succesfully. What am I doing wrong? I heard about using references to the hash instead? That's great but the reference would only be working in the script and not in the module right? Like here:#!/usr/bin/perl package Y; @ISA = qw(Exporter); @EXPORT_OK = qw(module_subroutine) sub module_subroutine { my($hash) = @_; return "The colour of the sky is ".$hash{third_colour}; }
I'm lost! Any help is very very welcome.return &Y::module_subroutine(\$hash_to_send);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Transferring local hashes to module subroutines
by EvanK (Chaplain) on Aug 06, 2008 at 02:44 UTC | |
|
Re: Transferring local hashes to module subroutines
by ikegami (Patriarch) on Aug 06, 2008 at 03:57 UTC | |
by cowgirl (Acolyte) on Aug 06, 2008 at 14:27 UTC | |
by EvanK (Chaplain) on Aug 06, 2008 at 14:45 UTC | |
by ikegami (Patriarch) on Aug 06, 2008 at 19:11 UTC | |
by dHarry (Abbot) on Aug 06, 2008 at 14:38 UTC | |
|
Re: Transferring local hashes to module subroutines
by chromatic (Archbishop) on Aug 06, 2008 at 03:32 UTC |