in reply to storing all type of vars

Your problem has nothing to do with references. You get the same behaviour if you store any scalar value. As busunsl points out, it's because you always return an array from get. Another solution would be to always use get in a list context, like this:

($refarr) = get();

As an aside, I'm not really sure what you're trying to do here. What can you do with put and get that you can't just use variables for?

--
<http://www.dave.org.uk>

Perl Training in the UK <http://www.iterative-software.com>

Replies are listed 'Best First'.
Re: Re: storing all type of vars
by eod (Acolyte) on Sep 11, 2001 at 15:18 UTC
    This code is (in some way) part of a Stack Module. The idea is to store whatever you want.

    I first start the Stack Module to store only hash vars.
    All the needs grow with time :) and I thought to store whatever I need using the same module.

    Sure I could find a Stack module in CPAN (I suspect) but is not funny and I learn less.

    Danke busunsl, fine answer.
    
    Sorry for my english (I try to learn too :) ).

      There doesn't seem to be a Stack module on CPAN, but that's probably more to do with the fact that it's simple to implement stacks in Perl using arrays.

      my @stack; push @stack, 'something'; push @stack, 'some thing else'; push @stack, ['something', 'a', 'bit', 'more', 'complex']; my $val = pop @stack;
      --
      <http://www.dave.org.uk>

      Perl Training in the UK <http://www.iterative-software.com>

        Yes!!, your answer make me feel like a fool.

        Using this to store a hash you have to store the reference, isn't it?:
        %hash =(uno=>1, dos=>2); push @stack, \%hash; %hash=%{pop @stack};
        With the stack module you don't have to care about this:
        $stack -> push(%hash); %hash = $stack->pop();
        Perhaps, slight difference to be worth.