Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
Perl
Perl Misc
use hash to name params, then stringify values in specific order
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
[QUOTE="DJ Stunks, post: 4861910"] Well, I think responder #1 missed what I was going for and responder #2 appears to be off his meds. However, I tried Tie::IxHash and it works quite well for me. It's immediately clear what the values are for the various API parameters and it skips the necessity of the @order array and the associated hash slice. The only concern is that maintainers must realize the order in the hash is critical. Code below for the curious. Thanks, Jake #/usr/bin/perl use strict; use warnings; use Tie::IxHash; tie (my %parms, 'Tie::IxHash'); #API syntax: my_API_call (<this_parameter>,<that_parameter>,<extra_parameter>) %parms = ( this_parameter => 'some value', that_parameter => 'another value', extra_parameter => 'a third value', ); my $stringified_API_call = 'my_API_call(' . join(',', values %parms) . ')'; print "call it: $stringified_API_call\n"; __END__ [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
Perl
Perl Misc
use hash to name params, then stringify values in specific order
Top