I have a program that is currently reading from FILE 1 , as shown below, and matches specific characters. eg
Type, Fruit, Description, quantity
tropical, banana, tasty and yummy, 5
tropical, grapefruit, bitter and not yummy, 2
... and so on
First of all, I wanted to create a hash of the hashes for each Type, Fruit, Description, Quantity, and store different values ββin the hashes of the links. This works well with the code below.
use strict; use warnings; use Data::Dumper; use Text::CSV; my %MacroA = ('Type' => {}, 'Fruit' => {}, 'Description' => {}, 'Quantity' => {}); open (my $file, '<', 'FRUITIES.txt') or die $!; while (my $line = <$file>) { if ($line =~ /\b(tropical)\b,/) { $MacroA{Type}->{$1}++; } if ($line =~ /,\b(banana|grapefruit)\b,/) { $MacroA{Fruit}->{$1}++; } if ($line =~ /,([\w\s]+?),/) { $MacroA{Description}->{$1}++; } if ($line =~ /,([\d]+?)/) { $MacroA{Quantity}->{$1}++; } } close $file;
So my question is: How can I put this data (the data is not corrected) in a csv file or something related (maybe xls), this will be a table with columns for each hash of the hashes ('Type', "Fruit", "Description ", "Number" ).
perl csv hash
El_commandantee
source share