Refers to the hash variable type in Perl. Other languages call this a dictionary or associative array.
Questions tagged [perl-hash]
71 questions
2
votes
2 answers
Adding multiple values to key in perl hash
I need to create multi-dimensional hash.
for example I have done:
$hash{gene} = $mrna;
if (exists ($exon)){
$hash{gene}{$mrna} = $exon;
}
if (exists ($cds)){
$hash{gene}{$mrna} = $cds;
}
where $gene, $mrna, $exon, $cds are unique ids.
But, my…

aki2all
- 429
- 1
- 8
- 24
2
votes
1 answer
perl error: 'use of uninitialized value in concatenation (.) or string' using hash
I have a tab-delimited file: abc.txt.
which has data like:
Pytul_T015270 Protein of unknown function
Pytul_T015269 Protein of unknown function
Pytul_T015255 Protein of unknown function
Pytul_T015297 Protein of unknown function
I am creating…

aki2all
- 429
- 1
- 8
- 24
2
votes
1 answer
How to map decoded json perl
I have problem to map all urls in decoded json content... I tried,but get error: Not a HASH reference...
$text = decode_json($document);
#print Dumper($text);
my @urls = map { $_->{'uri'} } @{$text->{children}->{children}};
print @urls;
Here…

Aleksandra Sretenovic
- 253
- 1
- 3
- 9
2
votes
2 answers
Perl:Access values of hash inside a hash
I have just picked up Perl.
I have a little confusion with accessing hash values. Below is the code where I am trying to access the values of a hash inside a hash.
Since am using a simple text editor to code, I am not able to figure out what can…

D_D
- 383
- 2
- 5
- 18
2
votes
1 answer
check whether 'hash key string' contains a word in perl
I want to check whether a particular word is present in key of hash.
I tried in the following way:
while (($key, $value) = each(%hash))
{
if( $key =~ /\b$some_word\b/ )
{
print"$key contains $some_word \n";
}
}
My question is there…

SS Hegde
- 729
- 2
- 14
- 33
2
votes
3 answers
Can I create a hash key in perl like this (lowerR-10,UpperR-12) => 1
I want to create a hash key in perl hash key that looks like this (lowerR-10,UpperR-12) => 1.
Here the key is (lowerR-10,UpperR-12) and its value is 1.
Actually I have a file like this. I have to find the overlap among the the elements.
A 10 12
A…

dissw.geek9
- 245
- 1
- 6
- 11
2
votes
3 answers
What's the difference between these two definitions?
Why it's a syntax error:
my @hash{1..4}=(1..4);
but not this one:
my %hash;
@hash{1..4}=(1..4);

bolbol
- 325
- 3
- 9
1
vote
2 answers
How to replace package name with a variable when using strictures
I have two Perl packages: pack_hash and pack_run
package pack_hash;
$VERSION = '1.00';
@ISA = qw( Exporter );
@EXPORT_OK = qw( %hashInfo );
$hashInfo{abc} = ['a', 'b', 'c'];
1;
package pack_run;
use stricts;
use warnings;
use…

Gaurab Banerjee
- 11
- 2
1
vote
2 answers
Passing multiple Hashes as argument to Perl subroutine ( Perl 5.16 / Perl 5.30)
We are trying to pass multiple hashes together with bunch of scalars as arguments to a subroutine. The problem is in multiple calls of this subroutine, ( and if we print the two hashes after we retrieved them inside the function), only one of them…

SS891
- 39
- 4
1
vote
1 answer
Match key elements in same hash with regex and store it in HoA
I have list of elements in a hash (%Hash).
I need to compare key elements each other and if one key matches with another key (with certain condition), then it would become a pair and should be stored it in HOA.
Here is my script:
use strict; use…

vkk05
- 3,137
- 11
- 25
1
vote
2 answers
Join same hash of arrays values
I have a hash with a certain set of data. I need to manipulate the hash values so that I can get result like below:
Expected Output:
key_1=Cell1
Val_1=C3#C4#C1#C2
Script:
#!/usr/bin/perl
use strict; use warnings;
use Data::Dumper;
use List::Util…

vkk05
- 3,137
- 11
- 25
1
vote
2 answers
How to print the previous Key Value in Perl?
In this code, I'm checking if a certain key is present or not.
Here I am checking if key "Uri" present. I am getting output as "3".
use strict;
use warnings;
my %Names = (
Martha =>2,
Vivek =>9,
Jason =>6,
Socrates=>7,
…

Alexx
- 475
- 2
- 8
1
vote
3 answers
How do I decipher an array of hashes?
I totally got this question wrong. Am using the method from TMDB:
my @results = $search->find(id => 'tt0114694', source => 'imdb_id');
I thought the output was in JSON format, so that's what confused me, which kept me running in circles…

LuisC329
- 131
- 8
1
vote
4 answers
Sort nested hash with multiple conditions
I'm somewhat new to perl programming and I've got a hash which could be formulated like this:
$hash{"snake"}{ACB2} = [70, 120];
$hash{"snake"}{SGJK} = [183, 120];
$hash{"snake"}{KDMFS} = [1213, 120];
$hash{"snake"}{VCS2} = [21,…
1
vote
4 answers
Benefits of using hash references?
I saw an article on perl script performance.
One of the things they mentioned is using hash references instead of accessing the hash directly each and everytime.
What benefit to do I gain from referring to the hash instead of a direct access?
My…

AtomicPorkchop
- 2,625
- 5
- 36
- 55