http://qs321.pair.com?node_id=11136854


in reply to Re^2: why is $1 cleared at end of an inline sub?
in thread why is $1 cleared at end of an inline sub?

maybe haukex understood your problem and you need to get acquainted with dynamic-scoping ... which is the only possible way to have limited control over global variables.

NB: our package-vars and special vars like $1 are global. They are accessible everywhere at run-time and prone to "sabotage".

Static aka lexical scoping is a totally different beast for my vars at compile-time.

Try to debug a global variable which suddenly changes after you called a sub from a foreign module you just upgraded.

And special vars are not protected by namespaces, they are all in main:: !

That's why they are automatically localized in subs.

Dynamic scoping was already a given in Perl4, which had no such thing like my or lexical scoping.

Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery