Mail Archives: cygwin/2003/04/14/10:34:24
On Mon, 14 Apr 2003, Greg Matheson wrote:
> On Sun, 13 Apr 2003, Igor Pechtchanski wrote:
>
> > It might be interesting to try writing a dummy perl module with a "print"
> > in its initialization subroutine, trying to "use" it after a "print" in
> > the main script, and seeing which print comes out first... I haven't
> > really written perl modules, so I can't perform the experiment myself
> > without a learning curve, but will do so if noone else does it first and
> > when time permits.
> > Igor
>
> greg AT 7106 ~
> $ echo 'print "hello from module\n";' > Module.pm
Wow, that easy, huh?
> greg AT 7106 ~
> $ perl -e 'print "hello from program\n";use Module;'
> hello from module
> hello from program
>
> I don't know if this carries over for setting $PATH, however.
This kind of proves my point (that use statements are executed before the
rest of the code). Also, the BEGIN block *is* executed before the
modules. See below:
$ echo 'print "ORACLE_HOME=$ENV{ORACLE_HOME}\n";' > Module.pm
$ perl -e '$ENV{ORACLE_HOME}="aaa bbb ccc";use Module;'
ORACLE_HOME=
$ perl -e 'BEGIN{$ENV{ORACLE_HOME}="aaa bbb ccc";}use Module;'
ORACLE_HOME=aaa bbb ccc
Hope this helps the OP.
Igor
--
http://cs.nyu.edu/~pechtcha/
|\ _,,,---,,_ pechtcha AT cs DOT nyu DOT edu
ZZZzz /,`.-'`' -. ;-;;,_ igor AT watson DOT ibm DOT com
|,4- ) )-,_. ,\ ( `'-' Igor Pechtchanski
'---''(_/--' `-'\_) fL a.k.a JaguaR-R-R-r-r-r-.-.-. Meow!
Knowledge is an unending adventure at the edge of uncertainty.
-- Leto II
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Bug reporting: http://cygwin.com/bugs.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/
- Raw text -