Syntactic Confectionery Delight | |
PerlMonks |
Re^3: Exporting all variables and subroutines using Exporterby BrowserUk (Patriarch) |
on Jul 14, 2016 at 07:06 UTC ( [id://1167761]=note: print w/replies, xml ) | Need Help?? |
that doesn't work Oh, but it does "work"; and has done since perl 4 days. Here's proof: fred.pm:
And junk33.pl that does it:
And the output from a run:
See subs and variables 'exported' into the calling code. Of course, if you enable warnings, you do get a few:
And if you enable strict, things start to fall apart:
And that is my point. do 'file' is "is almost forgotten, little used syntax," for a reason; Perl 5 vastly improved upon the mechanisms available in Perl4, by introducing packages & namespaces & lexical variables, and the tools (require & use) to make use of them. And in order to achieve what you are asking for in the OP, is to return to Perl4 -- which Perl will allow you to do -- but to achieve it you need to throw away namespaces and packages and lexical variables and strict & warnings. If you're prepared to do that, perl makes it simple. If you are not; then you might reconsider the reasons why you want to do it. I could have told you: thou shalt not; but it's better that you understand the reasons why it probably better that you don't; that you understand the trade offs; and what you have to give up in order to avoid re-structuring the code that you are so adamant that you cannot do. In other words; what you are asking for is doable; but given the trade-offs, you'll probably decide that you don't actually want to do it any more. But it is your decision to make. With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority". I knew I was on the right track :)
In the absence of evidence, opinion is indistinguishable from prejudice.
In Section
Seekers of Perl Wisdom
|
|