Buddyhelp has asked for the wisdom of the Perl Monks concerning the following question:
Currently I have a code that does something close to thisA|{NameTag}|Command|{Name}|{Parameters...}
my ($self,$nametag,$name,@params) = @_;#receives input from user my $tmp = { 'NameTag' => $nametag, 'Name' => $name, }; #i don't know how to extract the contents of @params and put it in the + $tmp hash my $InputRequest = $Obj->CreateString($tmp); } sub CreateString { ( my $self, my $hash ) = @_; $str = "A|" . $hash->{'NameTag'} . "|"."Command"."|" . $hash->{'Name'} . "|" return ($str); }
The problem is the user can send a command with multiple parameters in the form of an array like (a,b,c,d) the number of elements in the array may vary. HOw do I internally create a hash that can accomodate all the members of the array and concatenate it in the form a|b|c|d and put it in the form
A|{NameTag}|Command|{Name}|a|b|c|dPlease help.. I know only very basic perl.
Thank you
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Creating a dynamic hash from an array
by Athanasius (Archbishop) on Jun 08, 2012 at 15:01 UTC | |
|
Re: Creating a dynamic hash from an array
by stevieb (Canon) on Jun 08, 2012 at 15:56 UTC |