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

After battling with CGI.pm, cookies and redirection, this morning I finally made some progress when I changed my script from
print redirect ( cookie => $Cookie, uri => $URL );
to
print redirect ( -cookie => $Cookie, -uri => $URL );
Can someone explain the difference?

Another example is the login form: should there be hyphens in front of 'border', 'cellspacing' and 'cellpadding'?

print p, startform, table ( { border => 1, cellspacing => 0, cellpadding => 2 }, Tr ( th ( "UserID:" ), td ( textfield ( USERID ) ), td ( { rowspan => 2 }, submit ( "Login" ) ) ), Tr ( th ( "Password:" ), td ( password_field ( PASSWORD ) ) ) +), endform;
I have been using CGI.pm on and off for some time, and most of the time it works like a champ. Should I be thinking that I'm passing command line options in, hence the leading hyphen?

This is all based on merlyn's Basic Cookie Management column.

--t. alex
but my friends call me T.

Replies are listed 'Best First'.
Re: CGI.pm parameter format
by Joost (Canon) on Sep 12, 2002 at 13:31 UTC
    Most methods in CGI.pm have several ways of passing parameters:
    • As 'numbered' parameters (NOT using a leading dash)
      $q->method($param1,$param2);
    • As named parameters (with leading dash)
      $q->method(-name1 => $param1, -name2 => $param2)
    • As named parameters (with a hashref)
      $q->method( { name1 => $param1, name2 => $param2 } )
    Which one you want is up to you, but you cannot mix them, hence the insistance on a leading dash in variant 2.

    Hope this clears it up :-)
    Joost.

    -- Joost downtime n. The period during which a system is error-free and immune from user input.
      Excellent. That makes sense -- after spending much of the last 24 hours trying to figure this out, I finally see the light.

      Thanks brother Joost. :)

      --t. alex
      but my friends call me T.