Re: perl -s and use strict



On Mar 29, 3:26 am, chas.ow...@xxxxxxxxx (Chas Owens) wrote:
On 3/29/07, Sarthak Patnaik <sarthak.patn...@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

The vars pragma has been depreciated for about a decade. Please use
the our keyword.

perldoc -f our


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

Please, enlighten us as to what -s does that believe the OP did not
believe it does.
-s is perfectly fine for rudimentary command-line switching, for short
simple programs that don't need the bulk of the Getopt::* modules.

Paul Lalli

.



Relevant Pages

  • Re: perl -s and use strict
    ... Short answer: yes, the vars pragma ... use strict; ... my %opts; ...
    (perl.beginners)
  • Re: Please explain @{$y}
    ... from perldoc strict ... This generates a runtime error if you use symbolic references ... 'compile-time error' and 'runtime error' qualifications are at the start ...
    (perl.beginners)
  • Re: Web standards: smaller filesize?
    ... I'm trying to move from 4.01 Transitional to XHTML 1.0 ... Judge for yourself, www.High.St - all hand written on RISCOS, feedback ... I think that technically I could go to 1.0 Strict quite easily but one ...
    (comp.sys.acorn.misc)
  • Re: out of memory problem
    ... use strict; ... variable in the error message so you know *why* it ... foreach my $dir { ...
    (perl.beginners)
  • Re: How to extract the HTML tag?
    ... snip> And it should handle other rare cases, ... And right there you showed why regexes are not good for parsing HTML ... use strict; ... use warnings; ...
    (perl.beginners)