in reply to __END__ without __BEGIN__?

Assuming this isn't a troll...

Are you presuming the Perl compiler is psychic? How would it know that "b@d" at the beginning is to be skipped over? The current compiler is single pass... only once over the input file (which is why you can pipe a script from STDIN).

-- Randal L. Schwartz, Perl hacker
Be sure to read my standard disclaimer if this is a reply.

Replies are listed 'Best First'.
Re^2: __END__ without __BEGIN__?
by ktross (Deacon) on Mar 29, 2005 at 20:57 UTC
    No troll, just curious. Still...Even presuming the compiler is not phsycic, why can't you have a tag that says "forget what you have seen up to this point", when you have one that says "ignore the rest of the file?"
        b@d #! perl; print 'ignore b@d'; die;
        Will do what you want if started as perl -x your_script.pl

        CountZero

        "If you have four groups working on a compiler, you'll get a 4-pass compiler." - Conway's Law

        Hmmm, still requires the addition of code "<<END" before the data.

        Update: Yeah, I know I was wrong. Joost's solution works.

      You could probably do that (more or less) using source filters.

      use Filter::ignore-until-BEGIN-token; b@d __BEGIN__ print 'ignore b@d'; die;

      Now all that has to be done is writing the Filter::ignore-until-BEGIN-token-filter.

      We will leave that as an exercise for the reader. ;-)

      CountZero

      "If you have four groups working on a compiler, you'll get a 4-pass compiler." - Conway's Law

      At first glance it seems that this would be something easily accomplished with a source filter. Of course it's entirely possible I'm wrong since you would then be asking it to forget that it loaded the source filter.


      ___________
      Eric Hodges

        You can easily remove a source filter. The function in Filter::Util::Call for that is &filter_del. Filter::Simple has the "terminator" switch you can set.

        ihb

        See perltoc if you don't know which perldoc to read!