Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
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 ( [id://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?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (2)
As of 2024-04-25 19:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found