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

dereferencing data from multiple hash and array data structure in perl

Trying to extract data from detailed -> doc -> params -> parameters -> name in following DoxyDocs1.pm file; also including sample of script that extracts some data, but having trouble extracting params -> parameters -> name. Uncomment commented…
Jeff Cunningham
  • 145
  • 1
  • 11
0
votes
1 answer

Create array of structures in Perl

use Class::Struct; struct(TradeId => [ tradeIdScheme => '$', id => '$', ]); struct(VersionedTradeId => [ tradeId => 'TradeId', version => '$', effectiveDate => '@', ]); I would like to create an array of…
Ash
  • 693
  • 1
  • 6
  • 9
0
votes
2 answers

What is the best way to write and read XML in perl?

I am working with Perl programs that write to an XML file by just using the typical functions open, print, close. The XML files are later digested by a PHP Web application. #!/usr/bin/perl #opening file open FILE, ">derp.xml" or die $!; #data is…
Beau Bouchard
  • 835
  • 11
  • 28
0
votes
3 answers

How do I sort a parent-child list given a node relations data structure?

This drawing shows a tree of parent-child relationships. It is directed, without cycles. A child can have multiple parents. The corresponding array of arrays in Perl is: ( [A C], [B C], [D F G], [C E D], [E J X I], [I…
Gogi
  • 1,695
  • 4
  • 23
  • 36
0
votes
2 answers

calculate co-occurrences

I have a file as shown in the screenshot attached. There are 61 events(peaks) and I want to find how often each peak occurs with the other (co-occurrence) for all possible combinations. The file has the frequency (number of times the peak appears…
Tjb LaMac
  • 71
  • 6
0
votes
2 answers

Delete value from Perl hash of arrays of hashes

I'm trying to delete values from a hash of arrays of hashes that I created with the following code: while ((my $Genotype1, my $Fitness1) = each (%Normalisedfithash)) { while ((my $Parent1A, my $TallyP1) = each(%P1Tallyhash)) { my $ParentTally…
Lisa
  • 331
  • 1
  • 9
  • 15
0
votes
1 answer

Python to Perl translator, python indentations

I am translating Python to Perl for a project. I am asking for is a hint, or a starting point for my problem. Problem: How should I go about translating multi-line if/for/while statements in Python (assuming indentation for one block is equivalent…
dfj328
  • 367
  • 2
  • 13
-1
votes
1 answer

unique, count and sum values in perl

Possible Duplicate: How can I output unique, count and sum using perl How can I get unique, count and sum values in perl? My code is as follows: while (<$input>) { chomp; …
user1016594
  • 71
  • 1
  • 1
  • 2
-1
votes
2 answers

Replace the last line written to a file descritor

I am writing a small perl program where I am checking the pattern of #start and #end. The agenda is to create a separate file with the lines in between start and end patterns. This I am able to do with below script. #!/usr/bin/perl …
user1939168
  • 547
  • 5
  • 20
-1
votes
2 answers

Find elememts of first array in the second array and grep the lines matched with those of first array elements

I have two arrays.One of them has just strings and the other has lines matching the strings at random places. How can I grep the matched lines of second array with the elements of first array? Input_1: cpu soc disk mobile processor etc.. Input…
Manu
  • 1
  • 1
-1
votes
2 answers

Hashes of Arrays of Hashes of Arrays

I have the following output from hash in perl: $VAR1 = { 'ins_api' => { 'sid' => 'eoc', 'outputs' => { 'output' => [ { 'body' => { 'TABLE_interface'…
Andrew
  • 1
  • 1
-1
votes
1 answer

adding another key into perl hash reference is not working

Thanks in advance and your answer is most helpful. I am fetching two arrayofhashref using $sth->fetchall_arrayref({}) from Database let's a and b where a= [ { 'name' => 'test', 'id' => '10',`enter code here` …
-1
votes
1 answer

An issue with perl datatype conversion

My question is: I have something like this in my code my $offset = ‘0x4’ Out of this I want to extract only the value 4 and store it in a variable and discard ‘0x’, how can I do it. Please note that this is just an example the values will keep…
-1
votes
1 answer

Perl: Processing large files and storing into database

I have been tasked with modifying a Perl script which reads 12 files (~1GB each with ~4 million entries/file). The problem is that I don't know any perl. However, I was able to successfully modify the script for my use case. The problem is that the…
Naruto Uzumaki
  • 958
  • 4
  • 17
  • 37
-1
votes
2 answers

Format date time stamp

I get the output of perl gmtime(epoch) like below. Thu Jul 23 07:19:52 2015 I want to modify it to a directory name like below using perl. What's the best way ? 2015072307
Ani
  • 109
  • 2
  • 12