clueless newbie has asked for the wisdom of the Perl Monks concerning the following question:
Suppose warn.pm is
# warn.pm package CORE::GLOBAL; use strict; use warnings; use subs 'warn'; sub warn { print "WARN '@_'!\n"; CORE::warn @_; }; # die: 1;
and warn.pl is
# warn.pl #!/usr/bin/perl use strict; use warnings; warn 'first warn'; use warn; warn "second warn";
Then executing warn.pl produces
first warn at warn.pl line 6. WARN 'second warn'! second warn at warn.pm line 9.
Why doesn't the first warn (the warn prior to the "use warn;") utilize the CORE::GLOBAL::warn? Why in this case does the location of the "use warn;" matter?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Overriding CORE::GLOBAL::warn/die
by chromatic (Archbishop) on Sep 21, 2012 at 18:35 UTC | |
by clueless newbie (Curate) on Sep 21, 2012 at 18:53 UTC | |
|
Re: Overriding CORE::GLOBAL::warn/die
by Anonymous Monk on Sep 21, 2012 at 21:55 UTC | |
|
Re: Overriding CORE::GLOBAL::warn/die
by greengaroo (Hermit) on Sep 21, 2012 at 18:19 UTC | |
by clueless newbie (Curate) on Sep 21, 2012 at 19:01 UTC | |
by greengaroo (Hermit) on Sep 21, 2012 at 19:10 UTC | |
|
Re: Overriding CORE::GLOBAL::warn/die
by locked_user sundialsvc4 (Abbot) on Sep 21, 2012 at 18:42 UTC | |
by clueless newbie (Curate) on Sep 22, 2012 at 17:37 UTC |