in reply to Global symbol requires explicit package name

...this is a result of using strict. Your body would contain nothing if strict would allow it to execute. Look at the line:

$body .= "$in{$_}\n" for @param;

Before that line, where are you getting a %in? Set it and your code should 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

Replies are listed 'Best First'.
Re: Re: Global symbol requires explicit package name
by Nickd_69 (Novice) on Aug 15, 2003 at 01:24 UTC
    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??

      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

      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;