or would this be much better?
#!/usr/bin/perl -T
use strict;
use warnings;
use CGI();
use Mail::Mailer;
my $q = CGI-new();
# Email address where form submits are sent.
my $email = '[EMAIL PROTECTED]';
# Your subject for the form submits.
my $subject = '[INFO] Site Comment';
print
Jason Gray [EMAIL PROTECTED] wrote in message news:...
Could I do this?
sub check_fields {
my $q = shift;
my $match;
my @fields = ('name', 'email', 'city', 'state', 'message');
foreach my $field (@fields) {
next if ($q-param($field));
$match = 0;
print Please fill in your .
So would this solve the problem?
check_fields($q);
sub check_fields {
my $q = shift;
my @fields = qw(name email city state message);
foreach my $field (@fields) {
next if ($q-param($field));
print 'Please fill in the blank fields.';
exit;
}
unless
Is this how you were talking about getting rid of globals, and does this
seem correct?
#!/usr/bin/perl -T
use strict;
use warnings;
use lib '/home/perl-lib/modules';
use CGI;
use Email::Valid;
use Mail::Mailer;
my $q = CGI-new();
print $q-header();
check_fields($q);
sub check_fields {
my
Is this how you were talking about getting rid of globals, and does this
seem correct?
#!/usr/bin/perl -T
use strict;
use warnings;
use lib '/home/perl-lib/modules';
use CGI;
use Email::Valid;
use Mail::Mailer;
my $q = CGI-new();
print $q-header();
check_fields($q);
In
#!/usr/bin/perl -w
use strict;
use warnings;
use CGI();
use Mail::Mailer;
my $q = CGI-new();
print $q-header();
#-
# * startup methods - global variables.
check_fields();
#-
sub check_fields {
my $blanks;
my
Jason Gray wrote:
#!/usr/bin/perl -w
use strict;
use warnings;
use CGI();
use Mail::Mailer;
my $q = CGI-new();
print $q-header();
#-
# * startup methods - global variables.
check_fields();
#-
sub check_fields {
my
#!/usr/bin/perl -w
use strict;
use warnings;
You probably don't want both -w and 'use warnings'. Personally I would
stick with the 'use warnings' unless you have to deal with older
versions of Perl which is not terribly likely. The -w turns on warnings
for the whole script, which will
snip
my @fields = qw(name email city state message);
foreach my $field (@fields) {
$blanks++ if !$q-param($field);
}
for(@fields) { $blanks ++ if $q-param($_) eq ''; }
IMO, I disagree that removing whitespace and switching a named variable
such as $field to $_ is an
Please bottom post and group reply so everyone can help and be helped,
and you run less risk of being accidentally ignored...
Jason Gray wrote:
What do you exactly mean by passing $q as an argument?
In general you want to avoid the use of globals, and encapsulate your
subroutines such that they
10 matches
Mail list logo