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
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.