Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<blockquote> <p>but this seemed easier than combining spreadsheets in excel.</p> </blockquote> <p>Actually, modules like <a href="http://search.cpan.org/search?query=Spreadsheet-ParseExcel&amp;mode=module" rel="nofollow noreferrer">Spreadsheet::ParseExcel</a> make that really easy, in most cases. You still have to deal with rows as if from CSV or the "A1" type addressing, but you don't have to do the export step. And then you can output with <a href="http://search.cpan.org/search?query=Spreadsheet-WriteExcel&amp;mode=module" rel="nofollow noreferrer">Spreadsheet::WriteExcel</a>!</p> <p>I've used these modules to read a spreadsheet of a few hundred checks, sort and arrange and mung the contents, and write to a new one for delivery to an accountant.</p> <hr> <p>In this part:</p> <pre><code>foreach $subnet (sort keys %hash) { $tot = keys(%{$hash{$subnet}}); $days{$dt}{$subnet} = $tot; print FH "$subnet,$tot\n"; push @{$subnet}, $tot; } </code></pre> <p>$subnet is a string, but you use it in the last statement as an array reference. Since you don't have <a href="http://www.perlmonks.org/?node_id=686571" rel="nofollow noreferrer">strictures</a> on, it treats it as a soft reference to a variable with the name the same as the content of $subnet. Which is okay if you really want to, but it's confusing. As for clarifying the last part...</p> <p><em>Update</em> I'm guessing this is what you're looking for, where the subnet value is only saved if it hasn't appeared before, even from another day (?):</p> <pre><code>use List::Util qw(sum); # List::Util was first released with perl 5.007003 (5.7.3, I think) my %buckets; foreach my $day (sort keys %days) { foreach my $subnet (sort keys %{$days{$day}}) { next if exists $buckets{$subnet}; # only gives you this value once, regardless of what day it came in my $total = sum @{$subnet}; # no need to reuse a variable $buckets{$subnet} = int($total/@{$subnet}; # array in scalar context is number of elements } } use Data::Dumper qw(Dumper); print Dumper \%buckets; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload