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
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.