Home of the Squeezebox™ & Transporter® network music players.
Results 1 to 3 of 3
  1. #1
    Senior Member Aesculus's Avatar
    Join Date
    Jan 2008
    Posts
    433

    Global Scope of Hash

    Sorry to ask a basic PERL question but ...

    I have a hash variable that I declare in my Plugin.pm file at the top.

    I need this to be available both globally in Plugin.pm which it is, but also to other files too such as

    use Plugins:enonAvpControl:enonAvpComms;

    I have tried using both my and our with errors during starting LMS.

    What is the correct way to define this hash so it can be seen in routines in both files?
    Chris

  2. #2
    Babelfish's Best Boy mherger's Avatar
    Join Date
    Apr 2005
    Location
    Switzerland
    Posts
    20,601

    Global Scope of Hash

    > What is the correct way to define this hash so it can be seen in
    > routines in both files?


    Create an accessor method to get the variable (or a reference to it)
    from whereever you need

    sub getMyHash {
    \%myHash;
    }

    my $hashRef = Plugins:enonAvpControl::Plugin::getMyHash();

  3. #3
    Senior Member Aesculus's Avatar
    Join Date
    Jan 2008
    Posts
    433
    Thank you. Programming is not my strong suit and PERL is way down the list. :-)

    Of course thinking more about this I could probably also just pass the values back in a command in this context. In this case one file obtains and displays the results of actions performed by another file.
    Last edited by Aesculus; 2021-05-10 at 08:00.
    Chris

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •