I'd recommend you check out woolfy's Where and how to start learning Perl as there are some strange assumptions here, but a possible rewrite:

use strict;
use warnings; #good!
use Win32::OLE;
use Date::Calc; why load when you don't use it, or Win32::OLE?

#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) = l +ocaltime(time); $month++; $year += 1900; open (INFILE, $f_mfg_desk); #if you do my $record = <INFILE> you'd need chomp($record);... or while (<INFILE>) { 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"; }

*:localtime, perldsc, sort, perlref

"Cogito cogito ergo cogito sum - I think that I think, therefore I think that I am." Ambrose Bierce


In reply to Re^3: "Global Symbol Requires Explicit Package Name" error by kutsu
in thread "Global Symbol Requires Explicit Package Name" error by Portree

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.