Refers to the hash variable type in Perl. Other languages call this a dictionary or associative array.
Questions tagged [perl-hash]
71 questions
-1
votes
1 answer
The outputs were different in the terminal windows and txt file?
I am trying to merge two files by Perl.
Codes so far:
my $hash_ref;
open (my $I_fh, "<", "File1.txt") or die $!;
my $line = <$I_fh>;
while ($line = <$I_fh>) {
chomp $line;
my @cols = split ("\t", $line);
my $key = $cols[1];
$hash_ref ->…

Victor.H
- 157
- 1
- 8
-1
votes
1 answer
Reading/dumping a perl hash from shell
I have a read-only perl file with a huge hash defined in it. Is there anyway for me to read this perl file and dump out the hash contents?
this is basic structure of the hash within the file.
%hash_name = {
-files => [
'',
…

newbie
- 1
- 2
-1
votes
1 answer
return hash ref from a function in perl
I have written a function that executes a command, parses the output based on the regex, and returns two values, status and ip. Function call returns both the values as expected. Instead of returning a scalar, I want to return hash ref. Can some…

nims
- 103
- 1
- 8
-1
votes
1 answer
Compare 4 columns in two files; and output the line for unique combination (from first file) and line for duplicate combination (from second file)
I have two tab separated values file, say
File1.txt
chr1 894573 rs13303010 GG
chr2 18674 rs10195681 **CC**
chr3 104972 rs990284 AA <--- Unique Line
chr4 111487 rs17802159 AA
chr5 200868 rs4956994 **GG**
chr5 303686 …

Amit Goyal
- 29
- 3
-1
votes
2 answers
Check if pattern exists in a keys of hash
I have a hash of following pattern
my %hash_table(
23 => someintegertype,
type => somestringtype,
12_someidentifier => someveryproblematictype
);
How do I check if pattern that 12_someidentifier key…

Recker
- 1,915
- 25
- 55
-1
votes
1 answer
Perl: Iterating through large hash, runs out of memory
I have been trying to find values that match between two columns (columns a and column b) of a large file and print the common values, plus the corresponding column d. I have been doing this by interating through hashes, however, because the file is…

e2121
- 19
- 3
-2
votes
1 answer
How to sort perl hash?
I have the below hash structure, hash of hash.
$VAR1 = { '191' => { 'test1' => { 'score' => '9.18' }, 'test2' => { 'score' => '2.84' },
'test3' => { 'score' => '15.62' }, 'test4' => { 'score' => '11.84' },
'190' =>…

Akhil paul
- 7
- 6
-4
votes
1 answer
perl how to assign the individual values out to variable
I am trying to assign the hash values to variables, but I'm unable to get each value assigned to a varIAble. Please share your thoughts
say my %data = Dumper($data);
$VAR1 = {
'cnt' => 2000,
'inc' => 30,
'start' =>…

coolent
- 21
- 10
-4
votes
1 answer
Why is 1 assigned to a hash element?
Could any one explain what this statement does in Perl
$type{$_->{brand}} = 1;
I could understand that the hash %type has a key brand holding the reference to another hash brand and 1 is assigned to it
what does it mean??!!! when it is assigned as…
user2064238
-5
votes
1 answer
Can't use string ("") as a HASH ref while "strict refs" in use
Can't use string ("") as a HASH ref while "strict refs" in use
user9799283
-6
votes
1 answer
Printing array value from a hash in perl
I am new to perl and this thing is driving me nuts. I have a hash as below
%temp = (
a_collection => [\%first, \%second]
)
I want to get the array elements out as a string so i can use them as args in the loop. I have below code
foreach $item…

user775093
- 699
- 2
- 11
- 22