PERL: Global constant (1 Viewer)

HTPCSourcer

Retired Team Member
  • Premium Supporter
  • May 16, 2008
    11,418
    2,335
    Home Country
    Germany Germany
    Hi,

    I am running a FHEM server for home automation and have added some own PERL routines. FHEM loads modules that contain web calls.

    I would like to have one place to assign IP addresses to a variable/constant, unfortunately I couldn't figure out how to do this and ended up defining the same IP addresses in each module separately. Anybody out here who knows how to do this in PERL?
     

    HTPCSourcer

    Retired Team Member
  • Premium Supporter
  • May 16, 2008
    11,418
    2,335
    Home Country
    Germany Germany
    I figured that it's a P ;)

    The underlying challenge is to have a variable at level 1 from which sub modules get called. Indeed the subroutine would not know the value that was defined one level higher, yet other programming language allow the definition of global values.

    I have tried
    Code:
    use constant IP =>  ...
    But it would not be known in loaded pm modules. I am probably doing something wrong.

    Not a major thing. I stumbled again over it because I moved the vFHEM server to a Raspi Pi that got a new IP address and then forgot to update each occurrence of it.

    So your link is not exactly what I am looking for, but it' s a possibility.
     

    Users who are viewing this thread

    Top Bottom