[Omaha.pm] Golf my program :)

Jay Hannah jay.hannah at iinteractive.com
Thu May 24 07:52:49 PDT 2012


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 at iinteractive.com
AOL IM: deafferret
Mobile: 1.402.598.7782
Fax: 1.402.691.9496







More information about the Omaha-pm mailing list