in reply to Re^3: sub fuction inside sub functioin?
in thread sub fuction inside sub functioin?
but using the global namespace for an inner function is somehow dangerous. What if you call an external function within outer, that tries to call a completely different function also called inner()?
Maybe you should better use package to choose another namespace within outer() in combination with this local *name strategie to prevent this trap!
Cheers Rolf
UPDATE: Well OK, at least you get a warning ...
$\="\n"; sub inner { print "global_inner" } inner(); sub whatever { inner() } sub outer { local *inner=sub {print "inner_of_outer"}; inner(); whatever(); } outer(); __END__ Subroutine main::inner redefined at c:\perl\push.pm line 9. global_inner inner_of_outer inner_of_outer
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: sub fuction inside sub functioin?
by ikegami (Patriarch) on Dec 07, 2008 at 23:20 UTC | |
by LanX (Saint) on Dec 08, 2008 at 02:05 UTC | |
by ikegami (Patriarch) on Dec 08, 2008 at 02:52 UTC | |
by LanX (Saint) on Dec 08, 2008 at 02:56 UTC | |
by ikegami (Patriarch) on Dec 08, 2008 at 03:09 UTC | |
| |
by gone2015 (Deacon) on Dec 08, 2008 at 02:08 UTC |