damn.. i ment

sub cgi {
my $hashref = {};
.....
return ($hashref);
}

my $cgi = {};
$cgi = &cgi;
$cgi->{'varname'};

:) had {} after the sub :p

----- Original Message ----- 
From: "Pierre Smolarek" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>; "Martijn van Exel" <[EMAIL PROTECTED]>
Sent: Tuesday, July 03, 2001 10:52 AM
Subject: Re: Subroutine returning a hash (?)


> sub cgi {}
> my $hashref = {};
> .....
> return ($hashref);
> }
> 
> my $cgi = {};
> $cgi = &cgi;
> $cgi->{'varname'};
> 
> ----- Original Message -----
> From: "Martijn van Exel" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Tuesday, July 03, 2001 10:01 AM
> Subject: Subroutine returning a hash (?)
> 
> 
> > Dear subscribers,
> >
> > I was in a modular mood and thought it might just be a good idea to
> > do the parsing of the querystring in a subroutine. The subroutine
> > goes into a separate file that I then 'require' in all my future
> > CGI-scripts (is this a good way?).
> >
> > I thought it would be nice to return a hash with the key/value pairs
> > from my querystring. I was thinking of the following:
> >
> > sub parseit
> > {
> > foreach $name ($q->(param))
> > {
> > $input{$name} = $q->param($name);
> > }
> > return \%input;
> > }
> >
> > Because a subroutine cannot return a hash (or so I was told) I
> > instead return a reference to the hash. I'm not sure if this will
> > work. How would I access the data in my main cgi? Or am I making
> > things more difficult than they should be?
> >
> > 'There's always more than one way to do it' can be very confusing at
> times..
> > --
> > Martijn van Exel, [EMAIL PROTECTED]
> >
> > WEBkitchen
> > Waterstraat 11
> > 3511 BW Utrecht
> > tel/fax 030-6701818
> >
> > http://www.webkitchen.nl

Reply via email to