PERL: Global constant

Discussion in 'OffTopic' started by HTPCSourcer, June 16, 2016.

Tags:
  1. HTPCSourcer
    • Team MediaPortal
    • Administrator

    HTPCSourcer MP2 Product Manager

    Joined:
    May 16, 2008
    Messages:
    10,698
    Likes Received:
    1,118
    Gender:
    Male
    Ratings:
    +2,400 / 22
    Home Country:
    Germany Germany
    Show System Specs
    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?
     
  2. Google AdSense Guest Advertisement



    to hide all adverts.
  3. Ministerk
    • Super User

    Ministerk Super User

    Joined:
    November 28, 2007
    Messages:
    970
    Likes Received:
    401
    Occupation:
    Systems developer
    Location:
    Uppsala
    Ratings:
    +831 / 3
    Home Country:
    Sweden Sweden
    Show System Specs
  4. HTPCSourcer
    • Team MediaPortal
    • Administrator

    HTPCSourcer MP2 Product Manager

    Joined:
    May 16, 2008
    Messages:
    10,698
    Likes Received:
    1,118
    Gender:
    Male
    Ratings:
    +2,400 / 22
    Home Country:
    Germany Germany
    Show System Specs
    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 (Text):
    1. 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.
     
    • Like Like x 1
Loading...

Users Viewing Thread (Users: 0, Guests: 0)

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice
  • About The Project

    The vision of the MediaPortal project is to create a free open source media centre application, which supports all advanced media centre functions, and is accessible to all Windows users.

    In reaching this goal we are working every day to make sure our software is one of the best.

             

  • Support MediaPortal!

    The team works very hard to make sure the community is running the best HTPC-software. We give away MediaPortal for free but hosting and software is not for us.

    Care to support our work with a few bucks? We'd really appreciate it!