in reply to Re: Avoiding INIT
in thread Avoiding INIT

Thanks for the replies. Here's the context.

The module Getopt::Auto provides "magic" processing of command-line options. It uses processing in the INIT block to look at the command line before the body of the user's script is executed.

Thus, the INIT block is part of the user's code for execution purposes, but from the user's point of view, it isn't.

I'm just looking for a way of having the user not see the code. Sort of the opposite of $DB::single = 2.

Replies are listed 'Best First'.
Re^3: Avoiding INIT
by ikegami (Patriarch) on Feb 09, 2010 at 17:09 UTC

    Ah, you don't want to skip it's execution, you want to have the debugger not step through it. I'm rather surprised BEGIN blocks are simply executed rather than stepped through.

    Any reason you don't move the contents of your INIT block into your CHECK block?

      The idea it to postpone processing the command line until the last moment. The INIT block is just one sub call, prefixed, of course with an underscore to suggest that you (the user) really does not want to go there.

      The idea is to eliminate a potential source of confusion. I know that when I was developing tests I was constantly asking myself, "WTF is this?" before remembering that I was looking at the INIT block -- which I had written of course :-(.

        The idea it to postpone processing the command line until the last moment.

        That doesn't answer my question at all.

        Under the fair assumption that yours is the only module that has a CHECK block, the INIT block will be called immediately after the CHECK block. Thus, if the content of the INIT block were to be moved into the CHECK block, it would be executed at exactly the same time as before.

Re^3: Avoiding INIT
by Corion (Patriarch) on Feb 09, 2010 at 16:25 UTC

    Actually, if I had to go into the debugger to find out what/who is messing with @ARGV, and your code didn't show up in the debugger, I would be very unhappy.

      Well, fair enough. But that's only because you didn't RTFM :-)