[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Omaha.pm] Golf my program :)
Suggestions to improve this little program I just wrote?
https://github.com/jhannah/sandbox/blob/master/little_converter/convert.pl
open my $in, 'inputfile.txt' or die;
my ($lines, $column_count);
while (<$in>) {
chomp;
my @line = split /\t/;
$column_count = @line;
push @$lines, [ @line ];
}
my %line;
foreach $i (0 .. $column_count - 1) {
$line{$lines->[0]->[$i]} = $lines->[1]->[$i];
}
foreach my $k (sort keys %line) {
printf("%-30s %-20s\n", $k, $line{$k});
}
Jay Hannah
Project Lead / Programmer
http://www.iinteractive.com
Email: jay.hannah@iinteractive.com
AOL IM: deafferret
Mobile: 1.402.598.7782
Fax: 1.402.691.9496