#having a few variable with a large lexical scope isn't #nessarily bad but in general use the smallest scope # This acutally assigns the file location to a scalar # doesn't get anything (as [holli] stated) my %header_data; my $f_mfg_desk = '//163.../chicago_wip_query.txt'; # Since you don't actually use @headers: I dropped it # If you needed it just say why and I'll go from there # "time" gives seconds after epoch which is proably not what you want, see localtime* my ($sec, $min, $hour, $dayofmonth, $month, $year, $weekday, $day) = localtime(time); $month++; $year += 1900; open (INFILE, $f_mfg_desk); #if you do my $record = you'd need chomp($record);... or while () { chomp; my @newrow = split /\t/; #missing the ]; here $header_data{$newrow[2]} = [ $newrow[3..18] ]; } close(INFILE); #to sort and reprint (proably want to copy a backup too) open (OUTFILE, ">$f_mfg_desk"); # see perldsc* and sort* for my $key (sort keys %header_data) { #see perlref* for @{} for my $a (@{$header_data{$key}}) { print OUTFILE "$a\t"; } print OUTFILE "\n"; }