Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
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
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 about the Monastery: (4)
As of 2019-12-09 02:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?