Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re^3: creating a ksh wrapper in perl

by poj (Abbot)
on Jan 25, 2015 at 17:44 UTC ( [id://1114451]=note: print w/replies, xml ) Need Help??


in reply to Re^2: creating a ksh wrapper in perl
in thread pl c sv text format wrap

Try
use strict; use warnings; use Text::CSV; my @data; # 2D array for CSV data my %dict=(); my $file = 'AMS.csv'; my $csv = Text::CSV->new({ binary => 1, quote_null => 0 }); open my $fh, '<', $file or die "Could not open $file: $!"; while( my $ar = $csv->getline( $fh ) ) { if (@$ar > 2){ push @data,$ar; } elsif (@$ar == 2) { $dict{$ar->[0]} = $ar->[1]; } } open $fh, ">:encoding(utf8)", "PPS.csv" or die "PPS.csv: $!"; for my $ar (@data) { $ar->[0] = $dict{$ar->[0]}; $ar->[-1] = $dict{$ar->[-1]}; $csv->print($fh, $ar); print $fh "\n"; } close $fh or die "PPS.csv: $!";
poj

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (4)
As of 2024-04-24 05:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found