Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

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

by ISAI student (Scribe)
on Dec 14, 2012 at 07:30 UTC ( [id://1008791]=note: print w/replies, xml ) Need Help??


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

The answer is yes and no. refractoring the entire script is not an option for me right now. The script is with some bugs and not all that stable. The coupling may not be made looser for the global variables, but still, fixing bugs and adding functionality is easier on the human mind when the code is broken into many files, and use strict is applied. Although actually two monster hashes are used, the rest is very loosely coupled, instead of having almost everything coupled. The added complexity due to a few hash deferencing is linear. The added complexity of a multitude of lines of code and not using use strict is exponential (at least to me, I am an EE, not CS person). Even in Ruby, the self proclaimed OO queen, one can still globally loop on all instances of a certain class. This is a lexical analog , in a sense, that I have just 1 instance of this 1 "class". Some things, in any script that I know, are global (environment variables, for instance), this is, in a way for the usage fo these two hashes, similar. I need the management buy in to do what you suggest, and not w/o reason, I do not have it. I do understand where you come from, and would very much like to accept your offer, but it's not just up to me. Thank you for time.
  • Comment on Re^2: using eval or equivalent to automatically generate my statements

Replies are listed 'Best First'.
Re^3: using eval or equivalent to automatically generate my statements
by Athanasius (Archbishop) on Dec 14, 2012 at 15:05 UTC

    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,

      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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1008791]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (6)
As of 2024-04-24 06:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found