in reply to Re: Global symbol requires explicit package name
in thread Global symbol requires explicit package name

Thanks for taking a look. I'm only a newbie to perl so what exactly do you mean by that previous question? How would I go about setting what %in is? Should i just get rid of strict all together??
  • Comment on Re: Re: Global symbol requires explicit package name

Replies are listed 'Best First'.
Re: Re: Re: Global symbol requires explicit package name
by antirice (Priest) on Aug 15, 2003 at 01:33 UTC

    I understand you are just starting out. I have been following your posts as of recent days. Somewhere prior to the use of $in{$_}, you must declare %in with my %in.

    I must ask that you read some material prior to your continuation in perl. Check out perldata for information regarding variables and symbols in perl. Check out perlfunc and perlop for information on the various methods and operators available within the language. Be certain to read perlref, perllol and perldsc for more information regarding complex data structures and how they work.

    Hope this helps.

    antirice    
    The first rule of Perl club is - use Perl
    The
    ith rule of Perl club is - follow rule i - 1 for i > 1

Re: Re: Re: Global symbol requires explicit package name
by aquarium (Curate) on Aug 15, 2003 at 01:36 UTC
    insert a line just above the "for" loop:
    my %in;
    ...this declares a hash variable named "in". lookup perlvar section of perl documentation to learn about the basic variable types in perl.
    keep using strict, especially that you're newbie. it will make you always declare variables. so if you mis-spell a variable name when accessing it, perl won't create it for you automatically as it does without "use strict".
      Added the line of code you suggested and am now getting my favortie error premature end of script headers. Could you send me in the right direction to fix this problem which I always seem to get back to. Am reading some of the things you suggested now but they are fairly comprehensive and i don't really have time at the moment. Thanks for actually haveing some patience with me. Here is code so far:
      #!/usr/bin/perl -w use strict; use CGI; use CGI::Carp qw(fatalsToBrowser); use Mail::Mailer; my @param = qw( Title Name Position School Address Suburb State PCode Email Tel Fax Comments ); my $mailer = Mail::Mailer->new; $mailer->open({ To => 'foo@bar.com', From => 'baz@qux.com', Subject => 'results of submit', }); my %in; my $body; $body .= "$in{$_}\n" for @param; print $mailer $body; $mailer->close;
        Since this is a CGI process responding to a submitted form from a web browser, I believe the browswer is expecting to get some HTML data back, and it would get this when your script prints some amount of text to its STDOUT that qualifies as a valid HTML "page". But you are not printing anything out to STDOUT, so nothing is being returned to the browser.

        Look at the man page for the CGI module, for a simple example of how to output a minimal HTML "page" to keep the browser happy.