Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Off by one key... or yet another example of why strict and warnings are always a good idea (even for "one-liners")

by atcroft (Abbot)
on Jul 18, 2019 at 00:02 UTC ( #11102960=perlmeditation: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    # made-up example with actual issue
    $ perl -le 'my $str = q{zxcv}; if ( $str -~ m/some pattern/i ) { print
    + $str; }'
    zxcv
    
  2. or download this
    # made-up example with actual issue, with strict and warnings
    $ perl -Mstrict -Mwarnings -le 'my $str = q{zxcv}; if ( $str -~ m/some
    + pattern/i ) { print $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
    

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlmeditation [id://11102960]
Approved by LanX
Front-paged by haukex
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (None)
    As of 2021-10-18 01:32 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?
      My first memorable Perl project was:







      Results (72 votes). Check out past polls.

      Notices?