[Omaha.pm] Accessing CGI objects passed through a function call...

Dan Linder dan at linder.org
Thu Jun 24 09:57:38 PDT 2010


I'm trying to access the Perl CGI modules self_url call in a function
call.  Here's my code:

=== test001.pl ===
#!/usr/bin/perl
use lib ".";
use CGI;
use MyModule;
my $cgi = CGI->new();

show_my_link(\$cgi);
exit;
=== end test001.pl ===

My module is like this:
=== MyModule.pm ===
package MyModule;
use Exporter;
@ISA = qw(Exporter);
@EXPORT = qw(show_my_link);

sub show_my_link {
    my ($thecgi) = @_;
    printf ("The full URL is: %s\n", $thecgi->self_url());
}
1;
=== end MyModule.pm ===

When I run the code above, I get the error:
    Can't call method "self_url" on unblessed reference at MyModule.pm line 8.
(Line 8 is the printf...self_url line.)

I think I'm close, but is there something else I'm missing to make this call?

Thanks in advance!

Dan

-- 
***************** ************* *********** ******* ***** *** **
"Quis custodiet ipsos custodes?"
    (Who can watch the watchmen?)
    -- from the Satires of Juvenal
"I do not fear computers, I fear the lack of them."
    -- Isaac Asimov (Author)
** *** ***** ******* *********** ************* *****************


More information about the Omaha-pm mailing list