Questions tagged [perl-data-structures]

Discussion of Perl's three built-in data types: scalars, arrays of scalars, and associative arrays of scalars, known as "hashes". At your command-line: perldoc perldata

perldata - Perl data types

perldsc - Perl Data Structures Cookbook

388 questions
0
votes
1 answer

Can't use string ("Managers::Toke::Interface") as a HASH ref while "strict refs" in use at line 47

I'm building my first Perl constructor and I'm getting this error. Can't use string ("Managers::Toke::Interface") as a HASH ref while "strict refs" in use at Here is my constructor. package Managers::Toke::Interface; use strict; use warnings; use…
user1663896
  • 21
  • 1
  • 1
  • 5
0
votes
1 answer

Diff a data structure with a separate added and removed sections

let's say I have the following my $clean = { foo => 1, bar => 2, baz => 3, }; my $dirty => { foo => 1, bar => 3, blargh => 4, }; my $differ = Differ->new; #made up object $differ->compare( $clean, $dirty…
xenoterracide
  • 16,274
  • 24
  • 118
  • 243
0
votes
1 answer

perl cyclic reference. Is this what is happening

I am trying to write a daemon with perl. Now this daemon has the following code sub b { my $data; if (some condition) { $data->{"endsmeet"} = 1; } else { $data->{"endsmeet"} = 2; } my $newData = a($data); } sub…
0
votes
3 answers

Regarding store and retrieve in Perl

$stored_var = retrieve("$batch_text"); %some_hash= %$stored_var; i think that this is for retrieving some stored hash. what does the %$ signify? Is it just the syntax or does it have more involved meaning? store \%batch_hash, "$batch_text"; I…
RoyOneMillion
  • 225
  • 2
  • 10
0
votes
1 answer

hide attributes in object oriented perl

Recently I am using chilkat perl library for sending email http://www.example-code.com/perl/smtp_simpleSend.asp when i create new object use chilkat(); # The mailman object is used for sending and receiving email. $mailman = new…
pavan
  • 334
  • 6
  • 20
0
votes
1 answer

How to print hash of anonymous hashes?

How would I get value of stones if hash structure is as follows? %HoA = ( [stones => "ruby"], [metal => "gold"], ); I am trying to get using print $HoA->{stones};, but no value is returned.
Robie Nayak
  • 819
  • 10
  • 18
0
votes
2 answers

cant get array of hashes in perl

I have the Employees CSV Data and i try to insert each employee hash in to an array open($empOutFh,">empOut.txt") $hash= []; while(<$empFh>) { @columnNames = split /,/, $_ if $.==1; @columnValues = split /,/, $_; …
pavan
  • 334
  • 6
  • 20
0
votes
3 answers

Build and Access a Complex Data Structure Using Perl

I have a large one-dimensional hash with lots of data that I need to structure in such a way that I can sort it easily into a format that is the same each time the code executes. Original Hash Data: { 'datetime' => 'datetime value', 'param_name' =>…
Lane
  • 115
  • 2
  • 10
0
votes
1 answer

Perl prints only one line but the print to the screen works

I am trying to print a list of the devices that match my specific criteria. When I print everything to the screen, it works great. However, when I print it to a file it only prints one line. I am new to perl so any help would be appreciated.…
0
votes
3 answers

How to remove some entries in a file?

-rw-r--r-- 1 root root 3178 Jun 29 16:08 FTS_TESTCAMPAIGN1_29_06_2013_160823.html -rw-r--r-- 1 root root 711 Jun 29 16:08 FTS_ABORT_BACKUP_JOB_1_29_06_2013_160823.html -rw-r--r-- 1 root root 405 Jun 29 16:08…
user1954970
  • 409
  • 1
  • 5
  • 14
0
votes
2 answers

Perl:How to change values in global hash in sub-routine

I have a global hash our %employee = ( 'ename'=>"rahul", 'eno'=>"25", ); later I want to use it in a subroutine wid different values sub emp { print ("$employee->'ename' = 'satish'"); } but this is not happening can you please suggest…
0
votes
1 answer

XMLin not parsing XML properly

I have an XML as follows in $response_xml <?xml version="1.0"…
Chetan Bhise
  • 43
  • 1
  • 6
0
votes
2 answers

How to add an array of an array to values of hash?

I have an array a1 and an array-of-arrays a2. @a1 = [1,2,3,4,5] and @a2 = [ [adf],[bcg],[yet],[gpd],[iop]] I want to have a hash where a1 are the keys and arrays of a2 as values. How do I do it?
user2377038
  • 21
  • 1
  • 4
0
votes
2 answers

perl optional command line argument

I am new to Perl and wish to know if the following logic works in Perl :- I have to execute a command using Perl script with some arguments and I need to prepare that arguments list, some of the arguments are also optional ( may or may not…
Arpit
  • 4,259
  • 10
  • 38
  • 43
0
votes
2 answers

Use of uninitialized value

I'm trying to execute this simple code but it's already give me the following error : Use of uninitialized value $string in string at permutation.pl line 11. #!usr/bin/perl use strict ; use warnings ; sub message { my ($string) = @_ ; print…
Jacoberl
  • 63
  • 1
  • 4