Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re^2: Need to get hash of arrays

by haukex (Bishop)
on May 14, 2021 at 09:13 UTC ( #11132570=note: print w/replies, xml ) Need Help??


in reply to Re: Need to get hash of arrays
in thread Need to get hash of arrays

Or with Text::CSV/Text::CSV_XS:

use warnings; use strict; use Data::Dump; use Text::CSV; # also install Text::CSV_XS for speed my %data; my $csv = Text::CSV->new({ binary=>1, auto_diag=>2, sep_char=>"|", allow_whitespace=>1 }); my $hdr = $csv->getline(*DATA); while ( my $row = $csv->getline(*DATA) ) { push @{ $data{ $row->[0] } }, $row->[1]; } $csv->eof or $csv->error_diag; dd \%data; __DATA__ ColA | ColB | 500001| Network1| 500001| Network2| 500002| Network2| 500003| Network1| 500003| Network3|

Replies are listed 'Best First'.
Re^3: Need to get hash of arrays
by chandantul (Scribe) on May 15, 2021 at 18:40 UTC

    Hello Smart Monks, Thanks for your help. I have fixed this by below assignment

    push @{ $hash4{$cellp[$_]} }, $cellr[$_] for (0..$#cellp);

    I have fixed by below and lable as appropriate about within network or no network users

    if (grep { grep { $_ eq "No Network" } @{$hash4{$celln[$o]}} } keys %h +ash4) { worksheet->write($r12, 2, "Non Network"); }

    Thanks for your help.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11132570]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (5)
As of 2021-09-27 22:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?