In short, I think this may be all you need:

$self->xml()->$_() for values %{STUFF()};

You didn't describe the relationship between the various values and functions; what packages are in use; or what the functions do internally. I've made some (fairly gross) guesses for the test code below; hopefully, you can adapt this for your specific requirements.

#!/usr/bin/env perl -l use strict; use warnings; package With::Xml; sub new { bless {} => 'With::Xml' } sub xml { print "With::Xml::xml(): @_"; $_[0] } sub first_name { print "With::Xml::first_name(): @_" } sub last_name { print "With::Xml::last_name(): @_" } package main; use constant STUFF => { name1 => 'first_name', name2 => 'last_name', }; my $self = With::Xml::->new(); $self->xml()->$_() for values %{STUFF()};

Output:

With::Xml::xml(): With::Xml=HASH(0x7f9b998040b0) With::Xml::first_name(): With::Xml=HASH(0x7f9b998040b0) With::Xml::xml(): With::Xml=HASH(0x7f9b998040b0) With::Xml::last_name(): With::Xml=HASH(0x7f9b998040b0)

— Ken


In reply to Re: Calling a subroutine when part of call is a variable Contant by kcott
in thread Calling a subroutine when part of call is a variable Contant by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.