<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Impressive work Bradley! I tested it and it worked great, even with my&nbsp;mandatory&nbsp;'use strict'.<div><br><div>Thanks,</div><div><br></div><div>&nbsp;- Darren<br><div apple-content-edited="true"> <span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; "><div><br class="Apple-interchange-newline"><br></div><div>_____________________________</div><div><br></div><div>Darren Sessions</div><div><a href="mailto:dmsessions@gmail.com">dmsessions@gmail.com</a></div><div><a href="http://www.darrensessions.com">http://www.darrensessions.com</a></div><div><font class="Apple-style-span" face="Arial"><span class="Apple-style-span" style="line-height: 14px; white-space: pre-wrap; ">_____________________________</span></font></div><div><br></div></span></div></span></div></span></div></span></div></span><br class="Apple-interchange-newline"></div></span><br class="Apple-interchange-newline"></div></span><br class="Apple-interchange-newline"> </div><br><div><div>On Aug 29, 2008, at 5:47 AM, Watkins, Bradley wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div><br><blockquote type="cite">-----Original Message-----<br></blockquote><blockquote type="cite">From: <a href="mailto:asterisk-users-bounces@lists.digium.com">asterisk-users-bounces@lists.digium.com</a> <br></blockquote><blockquote type="cite">[<a href="mailto:asterisk-users-bounces@lists.digium.com">mailto:asterisk-users-bounces@lists.digium.com</a>] On Behalf Of <br></blockquote><blockquote type="cite">Darren Sessions<br></blockquote><blockquote type="cite">Sent: Thursday, August 28, 2008 10:12 PM<br></blockquote><blockquote type="cite">To: Asterisk Users Mailing List - Non-Commercial Discussion<br></blockquote><blockquote type="cite">Subject: [asterisk-users] Asterisk Tips and Tricks: Dynamic <br></blockquote><blockquote type="cite">Subroutines inAGI<br></blockquote>...<br><blockquote type="cite">The hurdle in doing something like this was how to <br></blockquote><blockquote type="cite">dynamically execute &nbsp;<br></blockquote><blockquote type="cite">a subroutine from the results of the database query which <br></blockquote><blockquote type="cite">were dumped &nbsp;<br></blockquote><blockquote type="cite">into a variable. The method I used with the subroutine reference &nbsp;<br></blockquote><blockquote type="cite">doesn’t allow for arguments to be passed (if anyone finds / knows a &nbsp;<br></blockquote><blockquote type="cite">way to do this, let me know), so I use global variables.<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">This is a simple example of dynamic subroutine execution <br></blockquote><blockquote type="cite">(without the &nbsp;<br></blockquote><blockquote type="cite">database query):<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">use strict;<br></blockquote><blockquote type="cite">use warnings;<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">our $called_number;<br></blockquote><blockquote type="cite">our $calling_number;<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">sub run_me {<br></blockquote><blockquote type="cite"> &nbsp;&nbsp;$AGI->verbose(”Called Number = “.$called_number, 1);<br></blockquote><blockquote type="cite"> &nbsp;&nbsp;$AGI->verbose(”Calling Number = “.$calling_number, 1);<br></blockquote><blockquote type="cite">}<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">sub set_variables {<br></blockquote><blockquote type="cite"> &nbsp;&nbsp;$called_number = “8005551212″;<br></blockquote><blockquote type="cite"> &nbsp;&nbsp;$calling_number = “3002221111″;<br></blockquote><blockquote type="cite">}<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">sub dynamic_execute {<br></blockquote><blockquote type="cite"> &nbsp;&nbsp;my ($sub) = @_;<br></blockquote><blockquote type="cite"> &nbsp;&nbsp;if (!$sub) {<br></blockquote><blockquote type="cite"> &nbsp;&nbsp;&nbsp;&nbsp;$AGI->verbose(”No subroutine name passed!!”, 1);<br></blockquote><blockquote type="cite"> &nbsp;&nbsp;&nbsp;&nbsp;return(-1);<br></blockquote><blockquote type="cite"> &nbsp;&nbsp;}<br></blockquote><blockquote type="cite"> &nbsp;&nbsp;my $exec = ¥&amp;{$sub};<br></blockquote><blockquote type="cite"> &nbsp;&nbsp;return($exec->());<br></blockquote><blockquote type="cite">}<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">set_variables();<br></blockquote><blockquote type="cite">dynamic_execute(”run_me”);<br></blockquote><br>If you don't mind disabling strict refs (no strict 'refs';), you could easily do this.<br><br>This would allow you to use something like: &amp;$sub($argument1, $argument2);<br><br>The only other way I can think of (though I have not tried it) would be to populate a hash with subroutine refs and use the string as the index into it. &nbsp;<br>Something like this:<br><br>#!/usr/bin/perl<br><br>use strict;<br>use warnings;<br>sub print_ref { print @_; };<br><br>my %sub_hash = ("print_ref", ¥&amp;print_ref);<br><br>sub print_stuff {<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;my $sub = shift;<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;my $string = shift;<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&amp;$sub($string);<br>}<br><br>print_stuff($sub_hash{"print_ref"}, "This is printed.¥n");<br><br><br><br>The first idea uses the symbol table directly, and the second one essentially is building your own symbol table.<br><br>Hope that helps,<br>- Brad<br><br>_______________________________________________<br>-- Bandwidth and Colocation Provided by <a href="http://www.api-digital.com">http://www.api-digital.com</a> --<br><br>AstriCon 2008 - September 22 - 25 Phoenix, Arizona<br>Register Now: <a href="http://www.astricon.net">http://www.astricon.net</a><br><br>asterisk-users mailing list<br>To UNSUBSCRIBE or update options visit:<br> &nbsp;&nbsp;<a href="http://lists.digium.com/mailman/listinfo/asterisk-users">http://lists.digium.com/mailman/listinfo/asterisk-users</a><br></div></blockquote></div><br></div></div></body></html>