passing $cgi object in hash.

S

sam

Hi,

I would like to pass the $cgi object to a subroutine from a hash object,
somehting like this:

#!/bin/usr/perl -w

use CGI;

sub testing
{
my ($obj1ref, $obj2ref, $str1, $str2, $cgi) = @_
$cgi->submit($str1.$str2);
}

$cgi = new CGI;

test($obj1,$obj2, "my", "string", $cgi);

Is it possible?

Thanks
Sam
 
S

sam

sam said:
Hi,

I would like to pass the $cgi object to a subroutine from a hash object,
somehting like this:

#!/bin/usr/perl -w

use CGI;

sub testing
{
my ($obj1ref, $obj2ref, $str1, $str2, $cgi_hash) = @_
$cgi_hash->{'cgi'}->submit($str1.$str2);
}

$cgi = new CGI;

test($obj1,$obj2, "my", "string", $cgi);

Is it possible?
Sorry, this is of course possible. I forgot pass it in a hash object
like below:

$cgi = new CGI;
my %_hash = ('cgi' => $cgi);
test($obj1,$obj2, "my", "string", \%_hash);
 
P

Paul Lalli

sam said:
Sorry, this is of course possible. I forgot pass it in a hash object
like below:

$cgi = new CGI;
my %_hash = ('cgi' => $cgi);
test($obj1,$obj2, "my", "string", \%_hash);

The obvious answer to a question of "is this possible" is "What happened
when you tried it?" If it worked, you're done. If not, you should be
asking "What does this error message mean?" or "Why didn't this work
correctly?" or "What is the correct way of doing this?"

So... what happened when you tried it?

Paul Lalli
 
T

Tad McClellan

sam said:
sam wrote:


The hash you show below is NOT an "object", it has not been
bless()ed into any class. It is a plain old hash.

my %_hash = ('cgi' => $cgi);
test($obj1,$obj2, "my", "string", \%_hash);


Errr, I thought the subroutine was named testing(), what is
this test() subroutine?

testing($obj1,$obj2, "my", "string", $_hash{cgi});
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,045
Latest member
DRCM

Latest Threads

Top