Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Perl Error - Can't call method "session" on an undefined value

by manukm (Initiate)
on Apr 24, 2013 at 04:30 UTC ( [id://1030275]=perlquestion: print w/replies, xml ) Need Help??

manukm has asked for the wisdom of the Perl Monks concerning the following question:

Please see the below code.

use strict; use warnings; use CGI; use vars qw($a); $a=new CGI; use Catalyst qw/ Session Session::Store::FastMmap Session::State::Cookie /; #@_=("1","2"); my ( $self, $c ) = @_; print $c->session->{foo} = "bar";

The file named as session.pl. When I run the above code(session.pl) I got the errors as given below in the server error log file.

1. Can't call method "session" on an undefined value at /var/www/ +birdbreeders/session.pl line 14 2. Premature end of script headers: session.pl

Please someone help me to clear the error.

Replies are listed 'Best First'.
Re: Perl Error - Can't call method "session" on an undefined value
by NetWallah (Canon) on Apr 24, 2013 at 05:34 UTC
    You will probably have to help yourself clear the error.

    $c is being assigned a value from @_.

    However, "@_" is not assigned a value.

    @_ might me beaningful inside a subroutine (passed parameters), but your code does not show any "sub", so @_ is empty, and perl's complaint is reasonable, since $c does not contain any value (it is undef).

    Your intentions for this code have not been expressed , and the code provided does not offer any clues, so we will not be able to assist.

                 "I'm fairly sure if they took porn off the Internet, there'd only be one website left, and it'd be called 'Bring Back the Porn!'"
            -- Dr. Cox, Scrubs

      Actually I was trying to set session using catalyst perl.
Re: Perl Error - Can't call method "session" on an undefined value
by Anonymous Monk on Apr 24, 2013 at 09:36 UTC

    Um, delete that file, and forget that it exists, and read the catalyst tutorial

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1030275]
Approved by GrandFather
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (4)
As of 2024-09-19 20:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    The PerlMonks site front end has:





    Results (25 votes). Check out past polls.

    Notices?
    erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.