Re: Passing hashes by reference.

From: ./Rob & (invalid_at_invalid.net)
Date: 09/30/04

  • Next message: Raymond Raj: "RE: Creating a word document"
    Date: Thu, 30 Sep 2004 00:06:10 -0400
    
    

    "krf" <krf@Vega.com> wrote in message
    news:pan.2004.09.30.00.31.10.861598@Vega.com...
    > If I call a perl module with a hash variable, like so...
    >
    > pass1(\%myhash);
    >
    > The hash shows up in $_[0] and the debugger thinks it is a hash.
    >
    > I can even use $_[0] as a hash over in the module.
    > Still normal so far.
    >
    > But if I do %anotherhash = $_[0], I get an undef in %anotherhash.
    >
    > Insights anyone??
    >
    > krf

    I think you need to do:
    %$anotherhash = shift;

    or $foo = shift;
    %anotherhash = %$foo;


  • Next message: Raymond Raj: "RE: Creating a word document"

    Relevant Pages

    • Re: Passing Argument to a Perl Module Function
      ... as a package method or a blessed reference to an object if invoked as ... an object method. ... instead of $_in your newmethod, or shift out the extra argument ...
      (perl.beginners)
    • Re: Source code for CAN Implementations
      ... very curious about insights. ... Now I desperately want to shift my self in to ... I appreciate for you kind information Paul ... Understanding can physical and data link layer implementations etc. ...
      (comp.arch.embedded)
    • Re: Source code for CAN Implementations
      ... very curious about insights. ... Now I desperately want to shift my self in to ... controllers on ISA/PCI boards. ...
      (comp.arch.embedded)