in reply to CGI::Tiny versus undefined parameter/form field

Can't call method "param" on an undefined value at /Users/me/PERL/ScriptDir/dev.pl line 1026.

This error message is telling you something very specific: you are invoking a method (called param) on something ($cgi) but the thing you are invoking it on is not a CGI::Tiny object but undef.

So all the rest is irrelevant: $cgi is not the object it is supposed to be, but undef. So you need to look at where $cgi is set, and diagnose what went wrong there (or somewhere in the pathway from there to line 1026).

Once you have fixed that, you can go back to your original line my $bookparam = $cgi->param('book') || ''; and I imagine it should work.

Replies are listed 'Best First'.
Re^2: CGI::Tiny versus undefined parameter/form field
by Polyglot (Chaplain) on Dec 11, 2022 at 21:35 UTC
    Are you saying that the error has nothing to do with whether or not that form field whose value is requested exists in the form? Because that is what the error message leads me to believe.

    I have initiated the CGI as seemed to be indicated in the package description, even copying the example verbatim. But try as I might, it doesn't work.

    It seems that it is quite new. There are no examples of code using CGI::Tiny that I was able to find online beyond that which I've already tried that comes with the package itself. Sigh, it looks like I'll just have to go back to good ole CGI.

    Blessings,

    ~Polyglot~

      You could try printing or otherwise inspecting the type of $cgi

      use Scaler::Util qw( reftype ); print reftype $cgi;

      That will tell you conclusively if $cgi is a CGI::Tiny object or undef.