lerameur wrote:
[...]
I tried using
use strict;
use warnings;
with the above program and it do not work.
"It does not work" it the worst possible problem description. Do you also go
to the doctor and just say "It hurts, please make it stop" without
explaining any symptoms or details? I strongly suggest you read
http://www.catb.org/~esr/faqs/smart-questions.html.
Proposal for a better question:
==========
When I'm adding
use strict;
use warnings;
to the above program then I am getting these error messages:
Global symbol "$line" requires explicit package name at C:\tmp\t.pl line
6.
Global symbol "$line" requires explicit package name at C:\tmp\t.pl line
7.
Global symbol "@items" requires explicit package name at C:\tmp\t.pl
line 8.
[and several more like this]
I checked perldoc and Google, but couldn't find an explanation. What do I
need to do to make the program strict and warnings compliant?
-OR-
I checked perldoc and Google, but I still don't understand these error
messages, could someone please explain?
-OR-
I checked perldoc and found this explanation
[Quote of text]
but I don't understand it. Could someone please explain?
-OR-
I don't understand these error messages and don't know where to start
looking for an explanation, could someone please post a pointer?
===========
Do you see the difference between your posting and the my suggestions above?
Then people would have pointed you to "perldoc perldiag" which has
explanations of all perl messages where it says
Global symbol "%s" requires explicit package name
(F) You've said "use strict vars", which indicates that all
variables must either be lexically scoped (using "my"), declared
beforehand using "our", or explicitly qualified to say which package
the global variable is in (using "::").
or to "perldoc strict" where it says
"strict vars"
This generates a compile-time error if you access a variable that
wasn't declared via "our" or "use vars", localized via "my()", or
wasn't fully qualified. [...] See the my entry in the perlfunc
manpage and the local entry in the perlfunc manpage.
use strict 'vars';
$X::foo = 1; # ok, fully qualified
my $foo = 10; # ok, my() var
jue