Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
I'm getting the same error in 5.26. What works is to use -B4 (i.e. no space).


$before = shift @ARGV assigns the first element of @ARGV to $before. The first element is -B, regardless of the Perl version. Also, changing the array you're currently iterating over doesn't seem to be a safe operation.

How to fix?

Iterate over the indices rather than elements if you want to peek into surrounding elements.
my $before; my $arg_index = 0; while ($arg_index < $#ARGV) { my $arg = $ARGV[$arg_index]; if( $arg =~ /^-B(\d+)$/ ) { # months Before $before = $1; } elsif( $arg =~ /^-B$/ ) { $before = $ARGV[++$arg_index]; if( $before !~ /^\d+/ ) { die "Bad before argument ($before)\n"; } } } continue { ++$arg_index; }

Note that the code doesn't report "Bad before" if there's no space after -B but the value is not a number.

How to fix properly?

Use Getopt::Long.

map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]

In reply to Re: hmm - - - something has changed in perl (from 5.34 to 5.36 by choroba
in thread hmm - - - something has changed in perl (from 5.34 to 5.36 by Anonymous Monk

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?

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

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (3)
As of 2023-03-23 23:20 GMT
Find Nodes?
    Voting Booth?
    Which type of climate do you prefer to live in?

    Results (60 votes). Check out past polls.