#!/usr/bin/perl
use strictandwarnings;
# use strict;
# use warnings;
# my $x;
print "$x\n";
$x = '$y';
print header(), start_html(), "\n";
strictandwarnings.pm after "fix":
package strictandwarnings;
require Exporter;
our @ISA = qw(Exporter);
sub import {
my ($pkg) = (caller)[0];
my $current = __PACKAGE__;
eval qq[
package $pkg;
use strict;
use warnings;
use CGI qw/:standard/;
package $current;
];
# optionally, if you still need import:
goto \&Exporter::import;
}
1;
t100.pl as is runs to completion with no warnings.
Un comment 'use strict' in t100.pl and it barfs with:
Global symbol "$x" requires explicit package name at ./tst100.pl line
+9.
Global symbol "$x" requires explicit package name at ./tst100.pl line
+11.
Execution of ./tst100.pl aborted due to compilation errors.
showing that had your code worked, the rpgram shouldn't have.
recomment use strict and uncommmment use warnings in t100.pl and it produces:
Use of uninitialized value in concatenation (.) or string at ./tst100.
+pl line 9.
followed by the correct output.
Your initial code said it did 3 things. It did none of them. 3 is more than 1. Hence 'multiply broken'.
And the OP did in fact use 'use strict' and 'use warnings' in the oringinal post. SOrry for not being a mind reader.
Note to whoever else keeps --'ing me: Have you tried to test the code, or do you just beleive this other guy when he says it works? Update: the original version of previous was much harsher, suspect that that is what was dissed.
--Bob Niederman, http://bob-n.com |