Questions tagged [hashref]

Use this tag for questions related to a hashref, an abbreviation to a reference to a hash.

Quoting this answer:

A hash is a basic data type in Perl. It uses keys to access its contents. A is an abbreviation to a reference to a hash. References are scalars, that is simple values. It is a scalar value that contains essentially, a pointer to the actual hash itself.

Make sure to use as well in your question.

82 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
2 answers

Iterating through a hashref arrayref

I have a nested data structure that I would like to iterate through but my code doesn't seem to be working. No error is displayed. The only way I can access the values is through Data::Dumper my $statuses = $nt->followers_ids({ screen_name =>…
-1
votes
3 answers

how to declare array reference in hash refrence

my $memType = []; my $portOp = []; my $fo = "aster.out.DRAMA.READ.gz"; if($fo =~/aster.out\.(.*)\.(.*)\.gz/){ push (@{$memType},$1); push (@{$portOp},$2); } print Dumper @{$memType}; foreach my $mem (keys…
Rahul Reddy
  • 12,613
  • 10
  • 22
  • 21
-1
votes
1 answer

Perl WWW:Mechanize Accessing data in a hash reference

I have a question I'm hoping you could help with? This is the last part I need help with in understanding hash references Code: my $content_lengths; # this is at the top foreach my $url ( # ... more stuff # compare if (…
yonetpkbji
  • 1,019
  • 2
  • 21
  • 35
-2
votes
1 answer

Perl dynamic hash traversal

A hash of (0 or more levels of hash refs of) array refs of hash refs. Note that the level above the leaf nodes will always be array refs, even if they only have one element. I need to fetch the aggregate sum of VALUE (in an array of array ref) by…
Aman Vidura
  • 85
  • 2
  • 10
-2
votes
1 answer

Perl array of hashrefs problems

I have this in my project: sub get_src_info($) { my $package = shift; my ($key,$value,$tail) =("","",""); my (@APT_INFO,$r); open APT, "apt-cache showsrc $package|"; while (){ chomp; …
1 2 3 4 5
6