Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re^2: Getopt - Validate arguments before processing -- BEGIN

by Corion (Patriarch)
on Jan 31, 2022 at 08:59 UTC ( [id://11140987]=note: print w/replies, xml ) Need Help??


in reply to Re: Getopt - Validate arguments before processing -- BEGIN
in thread Getopt - Validate arguments before processing

The code in the BEGIN block runs before Perl has even seen your declaration of the subroutine sub first { .... To work around that, you need to move the BEGIN block below the subroutine declaration(s).

Replies are listed 'Best First'.
Re^3: Getopt - Validate arguments before processing -- BEGIN
by Discipulus (Canon) on Jan 31, 2022 at 09:03 UTC
    yes thanks Corion, I know that.. but probably I have expressed it poorly :)

    > (but I moved the help sub on top, so it is parsed before the BEGIN block, so it can be called: you must move other subs to give them a chance to be called)

    I just wanted to suppress the warning but I was not able to find its category, and neither no warnings suppresses it

    L*

    There are no rules, there are no thumbs..
    Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.

      It's not a warning. It's a fatal error which GetOptions apparently catches and converts to a warning. And Corion told you how to fix it.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11140987]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (2)
As of 2024-04-25 06:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found