howdy, y'all...
was working with some of the great
tutorials here at the monestary and in doing so, begin playing with the -s switch...
while it is true that
Getopt::Std or
Getopt::Long are more flexible (and don't seem to have the same hangups with strict), i'm still interested in finding out whether the -s switch can work with strict...
below is posted a simple piece of code, just for the purposes of testing... if i
was feeling compelled to use the -s switch, i found the following worked, meaning produced the expected output:
#!/usr/local/bin/perl -s
use strict;
my ($var) = "This is the line that should be changed.";
my (@old) = split(/ /,$var);
no strict;
if ($z){
@old = map { tr/aeiou/AEIOU/; $_;} @old; #imagine many value
+s here
} else {
@old = "\nBlah-Blah\n";
}
use strict;
#imagine more code here
print "@old\n";
now if i run the script as
myprog.pl -zit will give the expected result, and without the switch, the else result...
without the
no strict; use strict wrap, it tells me i need to predefine
$z... but if i predefine it, the -s switch fails...
my question: assuming i
have to use the -s switch, and that my code will be more that 10 lines long and i want to use strict,
is there another way to use the -s switch and strict together?
Thanks in advance...
magnus