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

My lovely script (which works like a charm on 3 *nix Apache servers) gives this error when put onto this new IIs server: Undefined subroutine CGI::Vars I have the following line in my code but I can't see why it is a problem for one and not the other: my %FORM = $q->Vars('topic','words','pass','name','textsize','topicsize','edit');
Any advice?
TIA
jg
_____________________________________________________
If it gets a little bit out of hand sometimes, don't let it fool you into thinkin' you don't care.TvZ

Replies are listed 'Best First'.
(crazyinsomniac) Re: Error when script is on new IIs server from %FORM=$q-Vars
by crazyinsomniac (Prior) on Dec 13, 2001 at 12:09 UTC
    Not all CGI's are not created equal, behold:
    #!/usr/bin/perl -w use strict; use CGI; print "Version: $CGI::VERSION\n", "Revision: $CGI::revision\n";
    I suggest you crack open CGI.pm and check to see if Vars is in there, it'd be listed under %EXPORTED_TAGS as':cgi-lib' => [qw/ReadParse PrintHeader HtmlTop HtmlBot SplitParam Vars/], and it would look something like (from 2.752)
    # These are some tie() interfaces for compatibility # with Steve Brenner's cgi-lib.pl routines 'Vars' => <<'END_OF_FUNC', sub Vars { my $q = shift; my %in; tie(%in,CGI,$q); return %in if wantarray; return \%in; } END_OF_FUNC
    ar0n says you don't really need it, and that you can use my %form = map { $_ => $q->param($_) } @labels; to replicate the functionality, but be aware that Vars is significantly faster than the map method. in my benchmarks, Vars was at least %20 percent more efficient (it was significantly more, but I don't recall the exact number, i'll update in a minute).

     
    ___crazyinsomniac_______________________________________
    Disclaimer: Don't blame. It came from inside the void

    perl -e "$q=$_;map({chr unpack qq;H*;,$_}split(q;;,q*H*));print;$q/$q;"

(ar0n) Re: Error when script is on new IIs server from %FORM=$q-Vars
by ar0n (Priest) on Dec 13, 2001 at 10:32 UTC
    Err, why are you using CGI::Vars in the first place? It's old (from cgi-lib, I believe). Use param instead:
    my @labels = qw(topic words pass name textsize topicsize); my %form = map { $_ => $q->param($_) } @labels;

    [ ar0n -- want job (boston) ]

      Not true. Newer versions on CGI.pm Have a Vars subroutine for importing to a hash. Very useful :). jerrygarciuh probably just has an older version. I believe its versions 2.56 and above that have it but don't quote me on that :)

      Chris