Re: perl -s and use strict
- From: pangj@xxxxxxxxxxxxx (Jeff Pang)
- Date: Thu, 29 Mar 2007 14:39:40 +0800 (GMT+08:00)
#!/usr/bin/perl -ws
use strict;
print $k;
As I am using "use strict;", it is giving the following message:
Variable "$k" is not imported at ./test.pl line 3.
This is because you didn't declare that variable $k before using it.
You may do:
my $k; # declare $k as a lexical variable
or,
our $k; # declare $k as a package variable
For more info about perl's variable scope,see pls:
http://perl.plover.com/FAQs/Namespaces.html.en
.
- Follow-Ups:
- Re: perl -s and use strict
- From: Paul Lalli
- Re: perl -s and use strict
- Prev by Date: perl -s and use strict
- Next by Date: Re: sending output to file and terminal
- Previous by thread: Re: perl -s and use strict
- Next by thread: Re: perl -s and use strict
- Index(es):