Re: perl -s and use strict







#!/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

.