Re: perl -s and use strict
- From: chas.owens@xxxxxxxxx (Chas Owens)
- Date: Thu, 29 Mar 2007 03:26:03 -0400
On 3/29/07, Sarthak Patnaik <sarthak.patnaik@xxxxxxxxxxx> wrote:
snip
Is there any workaround for this, so that I can use strict and -s together.snip
Short answer: yes, the vars pragma
#!/usr/bin/perl -ws
use strict;
use vars qw($k);
print "$k\n"
Long answer: It is however a bad idea. -s does not do what you think
it does. It looks like what you want is the Getopt::Std module:
#!/usr/bin/perl
use warnings;
use strict;
use Getopt::Std;
my %opts;
getopt('k:', \%opts);
my $k = exists $opts{k} ? $opts{k} : "Default";
print "$k\n";
.
- Follow-Ups:
- Re: perl -s and use strict
- From: Paul Lalli
- Re: perl -s and use strict
- References:
- perl -s and use strict
- From: Sarthak Patnaik
- perl -s and use strict
- Prev by Date: Re: Exiting loops
- 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):
Relevant Pages
|