Good story, we've all been thru this once. =)

Just a hint

> (And yes, I do use the the duo on most every script I write-just not always on "one-liners".)

well you could set up an alias psw=perl -Mstrict -Mwarnings if you think that you'd really go to declare variables.

IIRC there was also a possibility to globally require a a piece of Perl code whenever your installation runs.

update

> where "-Mstrict -Mwarnings" would have added a mere 19 characters in length

or see perlrun#PERL5OPT: "Switches in this variable are treated as if they were on every Perl command line."

C:\>set PERL5OPT=-w -Mstrict C:\>perl -e"print $x" Global symbol "$x" requires explicit package name (did you forget to d +eclare "my $x"?) at -e line 1. Execution of -e aborted due to compilation errors.

though you might prefer to avoid strict vars in one-liners

C:\>set PERL5OPT=-w -Mstrict=refs,subs C:\>perl -e"print $x" Name "main::x" used only once: possible typo at -e line 1. Use of uninitialized value $x in print at -e line 1.

comming back to your original case

C:\>perl -le "my $str = q{zxcv}; if ( $str -~ m/some pattern/i ) { pri +nt $str; }" Use of uninitialized value $_ in pattern match (m//) at -e line 1. Argument "zxcv" isn't numeric in subtraction (-) at -e line 1. zxcv

Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery FootballPerl is like chess, only without the dice


In reply to Re: Off by one key... or yet another example of why strict and warnings are always a good idea (even for "one-liners") by LanX
in thread Off by one key... or yet another example of why strict and warnings are always a good idea (even for "one-liners") by atcroft

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":