Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
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":



  • 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.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (4)
As of 2024-04-19 22:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found