Bareword errors?
- From: gcr <reviewyourdemo@xxxxxxxxxxx>
- Date: Tue, 28 Nov 2006 14:45:51 -0500
Thanks for any opinions / advice / explanations / flames;
Short version -
getting an inconsistant (?) bareword error
strict accepts the first use of the bareword(?) but not later -
(not under strict one runs - the other gives error.
Long version:
how come the first bareword at line 15 passes? - right under getweb()
---snip
Bareword "search2" not allowed while "strict subs" in use at ./s1why.cgi
line 19.
Bareword "search1" not allowed while "strict subs" in use at ./s1why.cgi
line 22.
Bareword "search2" not allowed while "strict subs" in use at ./s1why.cgi
line 22.
----snip
when 'strict' isn't used:
----snip
Can't locate object method "HASH" via package "search2" (perhaps you
forgot to load "search2"?) at ./s1why.cgi line 19.
I'll hack around this but curious why first use passes.
This is perl, v5.8.1-RC3 built for darwin-thread-multi-2level
os x 10.3.9
-----snip -----
#!/usr/bin/perl
use strict;
my $search;
my %HASH;
my $name;
my $value;
my @pairs;
my $buffer;
my $pair;
getweb();
if (!$HASH{search1}) {
$search = "search2 only";
}
if (!HASH{search2}) {
$search = "search1 only";
}
if (!HASH{search1} && !HASH{search2}){
$search = "no search";
}
sub getweb() {
if ($ENV{'REQUEST_METHOD'} eq 'GET')
{
@pairs = split(/&/, $ENV{'QUERY_STRING'});
}
elsif ($ENV{'REQUEST_METHOD'} eq 'POST')
{
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
@pairs = split(/&/, $buffer);
}
foreach $pair (@pairs)
{
($name, $value) = split(/=/, $pair);
$name =~ tr/+/ /;
$name =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$value =~ s/<!--(.|\n)*-->//g;
$HASH{$name} = $value;
}
}
.
- Follow-Ups:
- Re: Bareword errors?
- From: Sherm Pendley
- Re: Bareword errors?
- From: Gunnar Hjalmarsson
- Re: Bareword errors?
- Prev by Date: Re: perl on Mac/OS X Tiger
- Next by Date: Re: Bareword errors?
- Previous by thread: perl on Mac/OS X Tiger
- Next by thread: Re: Bareword errors?
- Index(es):
Relevant Pages
|