Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked

Re: Hash Problem

by JediWizard (Deacon)
on Mar 08, 2007 at 15:57 UTC ( #603838=note: print w/replies, xml ) Need Help??

in reply to Hash Problem

The above responses will "fix" the error. However, if I were you, I would reconsider why you are passing a glob into ReadParse, as opposed to reference. From the simple example shown, you may even consider simply having ReadParse return a hash and take no input. As I rule, I try to avoid global variables, except when necessary (which it is not in the example given).

#get input my(%input) = &ReadParse(); ## OR my(%input) = (some_input => 'for the sub'); &ReadParse(\%input);

They say that time changes things, but you actually have to change them yourself.

—Andy Warhol

Replies are listed 'Best First'.
Re^2: Hash Problem
by davorg (Chancellor) on Mar 08, 2007 at 16:27 UTC

    All good advice, but unfortunately the poster is constrained by the fact that ReadParse is part of And the author of was constrained by the fact that ReadParse was written to be a drop-in replacement for the function of the same name from If you're interested, the code in looks like this:

    sub ReadParse { local(*in); if (@_) { *in = $_[0]; } else { my $pkg = caller(); *in=*{"${pkg}::in"}; } tie(%in,CGI); return scalar(keys %in); }

    Of course, ReadParse was only included in to ease the transition of moving code from to There's no reason at all why people should be using it these days. If you want to get a hash containing all the parameters (which is kind of what ReadParse does), then provides the far simpler and more flexible Vars function. And in most cases, you probably just want to be using param anyway as others have mentioned.

Re^2: Hash Problem
by ikegami (Pope) on Mar 08, 2007 at 16:19 UTC
    ReadParse wasn't written by the OP. It's part of CGI. It's there for backwards compatibility with cgi-lib, CGI's predecessor. (Needless to say, it shouldn't be used in new scripts.)
      Should I use:
      my $loginame=param("loginame");
      my $p_word=param("p_word");
        Yes, definitely.
Re^2: Hash Problem
by Anonymous Monk on Mar 08, 2007 at 16:19 UTC
    If a do this way
    #get input
    my(%input) = &ReadParse();
    I am not getting the values of $loginame and $p_word.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://603838]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (2)
As of 2021-06-18 05:08 GMT
Find Nodes?
    Voting Booth?
    What does the "s" stand for in "perls"? (Whence perls)

    Results (87 votes). Check out past polls.