in reply to Call sub in variable module

Try this:

{ package Fred123; sub xyz{ print "xyz() called from package ", __PACK +AGE__; }; };; { package Fred456; sub xyz{ print "xyz() called from package ", __PACK +AGE__; }; };; *{ "Fred${_}::xyz" }->() for 123, 456;; xyz() called from package Fred123 xyz() called from package Fred456

With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority". The enemy of (IT) success is complexity.
In the absence of evidence, opinion is indistinguishable from prejudice.

Replies are listed 'Best First'.
Re^2: Call sub in variable module
by tel2 (Pilgrim) on Nov 08, 2016 at 01:03 UTC
    Good answer, BrowserUk!
    Concise & cryptic, but effective...and it even works!
    Thanks for your response and keep up the good work.
    BTW, if you happen to know where I can read up about that *{ ... } syntax, please let me know.
    tel2
      BTW, if you happen to know where I can read up about that *{ ... } syntax, please let me know.

      Um. I'm not sure that I've ever seen any documentation for that particular construct.

      It is alluded to here, though if start here and move forward that might make more sense, but its pretty sparse.

      And if you read between the lines of that and the section of perlref on Symbolic References you'll get most of the gist.

      I you want my take on explaining it, yell and I'll try to work something up tomorrow.


      With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority". The enemy of (IT) success is complexity.
      In the absence of evidence, opinion is indistinguishable from prejudice.
        OK - thanks for that, BrowserUk.
        No need for further explanation at this stage.