in reply to Re: __END__ without __BEGIN__?
in thread __END__ without __BEGIN__?

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?"

Replies are listed 'Best First'.
Re^3: __END__ without __BEGIN__?
by Joost (Canon) on Mar 29, 2005 at 21:03 UTC
      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.

        The heredoc joost used is quoting for his shell, not perl. Put the following in a file (443263.pl, in my case) then run it using the -x command line switch.
        bla bla bla ignored #!perl #stuff_to_execute(); print "Hello, world!\n"; __END__ bla bla
        Output without -x: C:\S>perl 443263.pl syntax error at 443263.pl line 6, near "ignored" Execution of 443263.pl aborted due to compilation errors. With -x: C:\S>perl -x 443263.pl Hello, world!
        see perlrun for details
Re^3: __END__ without __BEGIN__?
by CountZero (Bishop) on Mar 29, 2005 at 21:22 UTC
    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

Re^3: __END__ without __BEGIN__?
by eric256 (Parson) on Mar 29, 2005 at 21:25 UTC

    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!