Use of uninitialized value in join or string at AlterDataNew.pl line 2
+9, <$FH> line 5.
Use of uninitialized value in join or string at AlterDataNew.pl line 2
+9, <$FH> line 5.
Use of uninitialized value in join or string at AlterDataNew.pl line 2
+9, <$FH> line 5.
Use of uninitialized value in join or string at AlterDataNew.pl line 2
+9, <$FH> line 5.
Use of uninitialized value in join or string at AlterDataNew.pl line 2
+9, <$FH> line 5.
Use of uninitialized value in join or string at AlterDataNew.pl line 2
+9, <$FH> line 5.
Error parsing time at /usr/perl5/5.12/lib/sun4-solaris-64int/Time/Piec
+e.pm line 470, <$FH> line 5.
And here is the entirety of my script currently with your line added -
#!/usr/bin/perl/
use strict;
use warnings;
use Data::Dumper;
use Time::Piece;
my $filename = 'tested.csv';
open my $FH, $filename
or die "Could not read from $filename <$!>, program halting.";
# Read the header line.
chomp(my $line = <$FH>);
my $i = 0;
$line = join '', grep { $i++ % 2 ? {s/,/ /g} : 1} split /"/,$line;
my @fields = split(/,/, $line);
print Dumper(@fields), $/;
my @data;
# Read the lines one by one.
while($line = <$FH>) {
# split the fields, concatenate the first three fields,
# and add it to the beginning of each line in the file
chomp($line);
my @fields = split(/,/, $line);
unshift @fields, join '_', @fields[0..2];
$_ = join '-', (split /\//)[2,0,1] for @fields[14,20,23];
$_ = Time::Piece->strptime($_,'%m/%d/%Y %H:%M')->strftime('%Y-%m-%
+d %H:%M') for @fields[38,39];
push @data, \@fields;
}
close $FH;
print "Unsorted:\n", Dumper(@data); #, $/;
@data = sort {
$a->[0] cmp $b->[0] ||
$a->[20] cmp $b->[20] ||
$a->[23] cmp $b->[23] ||
$a->[26] cmp $b-> [26]
} @data;
open my $OFH, '>', '/swpkg/shared/batch_processing/mistints/parsedMist
+ints.csv';
print $OFH join(',', @$_), $/ for @data;
close $OFH;
exit;
|