CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
Can't call method "header" on an undefined value at /.../login.pl line 19.

 



ningji
Novice

Jan 14, 2013, 8:43 AM

Post #1 of 5 (1021 views)
Can't call method "header" on an undefined value at /.../login.pl line 19. Can't Post

Can't call method "header" on an undefined value at /.../login.pl line 19.

# process the form
if($usr eq "demo" and $pwd eq "demo")
{
$session = new CGI::Session();
print $session->header(-location=>'index1.pl');
}


This is the sample i copied from web, what does this error mean pl ?
Attachments: login.pl (0.92 KB)


rovf
Veteran

Jan 15, 2013, 2:05 AM

Post #2 of 5 (1011 views)
Re: [ningji] Can't call method "header" on an undefined value at /.../login.pl line 19. [In reply to] Can't Post

It would mean that $session is undef. You could write explicitly


Code
$session = new CGI::Session() or die "Can not create CGI::Session object";


to be sure.


rovf
Veteran

Jan 15, 2013, 2:07 AM

Post #3 of 5 (1010 views)
Re: [ningji] Can't call method "header" on an undefined value at /.../login.pl line 19. [In reply to] Can't Post

BTW, have a look at perldoc CGI::Session:


Constructor. Returns new session object, or undef on failure. Error message is accessible through errstr() - class method.



ningji
Novice

Jan 15, 2013, 7:43 AM

Post #4 of 5 (1000 views)
Re: [rovf] Can't call method "header" on an undefined value at /.../login.pl line 19. [In reply to] Can't Post

errstr( ) gives error message, great !

new(): failed: couldn't load CGI::Session::Serialize::default: Can't locate Safe.pm in @INC (@INC contains: /etc/perl /usr/local/lib/perl/5.10.1 /usr/local/share/perl/5.10.1 /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.10 /usr/share/perl/5.10 /usr/local/lib/site_perl .) at /usr/share/perl/5.10/CGI/Session/Serialize/default.pm line 6.
BEGIN failed--compilation aborted at /usr/share/perl/5.10/CGI/Session/Serialize/default.pm line 6.
Compilation failed in require at (eval 7) line 3.


The problem is i cannot find Safe.pm.
I downloaded Session.pm from
http://packages.debian.org/stable/perl/libcgi-session-perl

Anyone knows where Safe.pm is ?


In Reply To
BTW, have a look at perldoc CGI::Session:


Constructor. Returns new session object, or undef on failure. Error message is accessible through errstr() - class method.



FishMonger
Veteran / Moderator

Jan 15, 2013, 9:15 AM

Post #5 of 5 (996 views)
Re: [ningji] Can't call method "header" on an undefined value at /.../login.pl line 19. [In reply to] Can't Post

Safe.pm is a core module (Safe was first released with perl 5.002), which means that it should have been included in the base install of perl.

If it's not on your system, then I'd say that your perl installation is broken. You could use cpan to install the module, but if this core module is missing, the next question you should ask yourself is "what other core modules are missing?".


(This post was edited by FishMonger on Jan 15, 2013, 9:15 AM)

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives