ktross has asked for the wisdom of the Perl Monks concerning the following question:
Why does perl have and __END__ token, but not a __BEGIN__ token?
Why are we permited to store data only at the end of a file?
Is it unreasonable to want to attach runnable perl code to the end of a file?
What I mean is, why is this forbidden:
but this allowed:b@d __BEGIN__ print 'ignore b@d'; die;
There is a defined BEGIN{} subroutine that is the first thing run when a perl script is called, but perl decides that running it is un-safe if there are syntax errors anywhere in the file. For example:print 'ignore b@d'; die; __END__ b@d
Does not run.b@d BEGIN{ print 'ignore b@d'; die; }
Am I missing something?
update:perl -x is close enough for me =)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: __END__ without __BEGIN__?
by merlyn (Sage) on Mar 29, 2005 at 20:52 UTC | |
by ktross (Deacon) on Mar 29, 2005 at 20:57 UTC | |
by Joost (Canon) on Mar 29, 2005 at 21:03 UTC | |
by CountZero (Bishop) on Mar 29, 2005 at 21:30 UTC | |
by ktross (Deacon) on Mar 29, 2005 at 21:21 UTC | |
by Joost (Canon) on Mar 29, 2005 at 21:27 UTC | |
by bmann (Priest) on Mar 29, 2005 at 21:38 UTC | |
by CountZero (Bishop) on Mar 29, 2005 at 21:22 UTC | |
by eric256 (Parson) on Mar 29, 2005 at 21:25 UTC | |
by ihb (Deacon) on Mar 30, 2005 at 09:24 UTC | |
|
Re: __END__ without __BEGIN__?
by moot (Chaplain) on Mar 29, 2005 at 21:26 UTC | |
by Anonymous Monk on Mar 30, 2005 at 12:12 UTC | |
by moot (Chaplain) on Mar 30, 2005 at 14:23 UTC | |
|
Re: __END__ without __BEGIN__?
by gaal (Parson) on Mar 30, 2005 at 14:42 UTC | |
|
Re: __END__ without __BEGIN__?
by NateTut (Deacon) on Mar 30, 2005 at 18:10 UTC |