Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
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 surveying the Monastery: (5)
As of 2022-10-07 16:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My preferred way to holiday/vacation is:











    Results (30 votes). Check out past polls.

    Notices?