in reply to csv to hash table
$inputfile1 =~ s/\s*\z//;
$inputfile1 is your filehandle, but you are editing that filehandle and thus corrupting it. Try:
sub mainCSV { open (my $inputfile1, '<', "$inputfile") or die "Unable to open $i +nputfile1: $!"; my %hash; while( my $line = <$inputfile1> ) { $line =~ s/\s*\z//; my @arrayfile1 = split /,/, $line; my $keyfile1 = shift @arrayfile1; $hash{$keyfile1} = \@arrayfile1; } print %hash; close $inputfile1; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: csv to hash table
by waytoperl (Beadle) on Nov 19, 2013 at 05:41 UTC | |
by BrowserUk (Patriarch) on Nov 19, 2013 at 06:21 UTC | |
by waytoperl (Beadle) on Nov 19, 2013 at 09:10 UTC | |
by Corion (Patriarch) on Nov 19, 2013 at 09:18 UTC | |
by locked_user sundialsvc4 (Abbot) on Nov 19, 2013 at 14:56 UTC | |
by choroba (Cardinal) on Nov 19, 2013 at 15:42 UTC | |
by waytoperl (Beadle) on Nov 19, 2013 at 18:40 UTC | |
|