Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re^3: using eval or equivalent to automatically generate my statements

by Athanasius (Monsignor)
on Dec 14, 2012 at 15:05 UTC ( #1008852=note: print w/ replies, xml ) Need Help??


in reply to Re^2: using eval or equivalent to automatically generate my statements
in thread using eval or equivalent to automatically generate my statements

Yes, I can see that re-design is not an option for you at the moment, and I agree that modularising and adding use strict will aid both debugging and enhancement.

But why make it all so complicated? You can have lexical variables which are strict-compliant and still package-global — just use our instead of my:

# File: main.pl #! perl use Modern::Perl; use Foo; our $Id = 42; Foo::foo_id(); say 'In main, $Id is ', $Id; ... # File: Foo.pm package Foo; use Modern::Perl; sub foo_id { say 'In Foo, $main::Id is ', $main::Id; $main::Id = 17; } 1;

Output:

In Foo, $main::Id is 42 In main, $Id is 17

You can of course get fancier with @EXPORT, @EXPORT_OK, etc., but using the fully-qualified package names is probably a better strategy as it makes the trail of the global variables self-documenting.

Hope that helps,

Athanasius <°(((><contra mundum Iustus alius egestas vitae, eros Piratica,


Comment on Re^3: using eval or equivalent to automatically generate my statements
Select or Download Code
Re^4: using eval or equivalent to automatically generate my statements
by ISAI student (Scribe) on Dec 16, 2012 at 08:19 UTC

    I didn't use PERL's our becaue I know PERL not as well as you do.

    That's the root cause of me being on this site, asking nebiew's questions... Thanks for the lead.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1008852]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (12)
As of 2014-07-31 20:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (252 votes), past polls