I'm not sure that question makes much sense. What do you want to use for the hash key and what will the values be (where do they each come from). The array only supplies one - the key or the value.
Perhaps you need to define your problem a little more? It may help to give a little sample data and show us the code that you have tried and are having problems with. It helps even more if you show us what your code prints and what you expected it to print.
use strict; use warnings; use Data::Dumper; my @array; # do whatever to populate the array print Dumper \@array;And show us a (short) sample of the output.
Also, to help you on your way, have at look at these tutorials:
Depending on whether you're dealing with an actual array, or an associative array (a hash), the answer could be either of the following:
my $search = $data[2];
...or...
my $search = $data{content};
...assuming your array or hash are named @data or %data.
And this assumes also that I understood your ambiguously worded question. If I misunderstood it, please rephrase it in a followup so we can gain a better understanding of your need.
Dave
my $search = $field[2];
Regards,
Murugesan Kandasamy
use perl for(;;);
barrycarlyon: you appear to have been working at this problem for some time now.
Try posting some more of the code from your program, giving us a fully funcational version that operates on or some other construct, with expected input, and output, as well as actual output (containing the problem you're running into) so that we can see exactly what you're doing, so perhaps we can help you better.
If this node is related to [id://539034|your other node], then perhaps all you need to do is:
$search = ( split / /, $data ); # or $search = @$data[2]; # or $search = $results[2];
... but really, it's hard to give an accurate answer to your queries without a better defined question! :-)
The way this particular question is worded, it looks like you've got a hash whose value you'd like to get, which would be written as:
$search = $array_name{'content'};
Please, help us help you a bit better :)
$,=42;for(34,0,-3,9,-11,11,-17,7,-5){$*.=pack'c'=>$,+=$_}for(reverse split//=>$*
){$%++?$ %%2?push@C,$_,$":push@c,$_,$":(push@C,$_,$")&&push@c,$"}$C[$#C]=$/;($#C
>$#c)?($ c=\@C)&&($ C=\@c):($ c=\@c)&&($C=\@C);$%=$|;for(@$c){print$_^$$C[$%++]}
while (my @row = $sth->fetchrow_array){@search=($row[2]);}
I'd understand a bit better. You specify in [id://541150|other post] that your query only returns one row in this case, but what does your array look like if your query returns more than one row?
perlmonks.org content © perlmonks.org and barrycarlyon, chargrill, davido, GrandFather, murugu, SamCG, wfsp
prlmnks.org © 2006 edmund von der burg (eccles & toad)
v 0.03