#!/usr/bin/perl -w

$| = 1;
# Codes start...

#my $date =`date '+%Y-%m-%d %H:%M:%S'`;
#my $date2 =`date '+%Y-%m-%d %H:%M:%S'`;
#print "start at: $date  and end at $date2\n";

my $filename = "/tmp/ChryslerInventory6-17-14.csv";
open ( my $fh, $filename) 
    or die "Can't open file $filename \n";
my ($rname,$category,$manufacturer,$model,$serial,$barcode,$location,$dateAcquired,$status);
my $i=0;    

my $map = {
    manufacturer=> 2,
    model       => 3,
    serial      => 4,
    barcode     => 5,
    location    => 9,
    dateAcquired=>12,
    status      =>13,

};
my $mapCategory = {
    
};


print "equipment name \t\t\t\t manufacturer \t model\t\t\t serial\t barcode \t location\n";

while( my $row = <$fh> ) {
 #if ($i>10) {      last;  }
        
 chomp $row;
 #print "$row \n";
 my @row = split(",", $row);
 $rname = $row[1] ." " . $row[2] . " - " . $row[3];
 $rname =~ s/"//g;
 $manufacturer = $row[$map->{'manufacturer'}];
 $manufacturer =~ s/"//g;
 $model = $row[$map->{'model'}];
 $model =~ s/"//g;
 $serial = $row[$map->{'serial'}] ;
 $serial =~ s/"//g ;
 $barcode = $row[$map->{'barcode'}];
 $barcode =~ s/"//g;
 $location = $row[$map->{'location'}];
 $location =~ s/"//g;
 $dateAcquired = $row[$map->{'dateAcquired'}];
 $dateAcquired =~ s/"//g;
 $status  = $row[$map->{'status'}];
 $status  =~ s/"//g;
 
 print $rname,"\t",$manufacturer,"\t",$model,"\t",$serial,"\t",$barcode,"\t",$location,"\t",$dateAcquired,"\t",$status,"\n";
 $i++;
}
print "done";

close($fh);

# Codes end.

exit 0;
############################################################
