in reply to Re: "Global Symbol Requires Explicit Package Name" error
in thread "Global Symbol Requires Explicit Package Name" error

Hello All
I have read over all of your comments, and I understand to an extent what you are saying. I am a lowly hacker trying to automate a report. Below is the updated code I have, but I am now getting a new error. Here is what I ultimately want to do, and if someone can point me to a straight forward source then I am happy to try as much on my own as I can.

I have a tabe delimited file. I want to eliminate rows where the date in column "Cust Late Shp Dt" is greater than today. Then I want to sort the data by the same field. Then save the data and put it back in the same location as I got it from. Below is the code that I have so far, but if I need to start completely over I will, just so I can get this done. Once I have the template and understand it, I think I can then apply it to several other reports. Thank you in advance for all of your help.
use strict; use warnings; use Win32::OLE; use Date::Calc; my ($f_mfg_desk, $f_mfg_desk_output, @wip_query, $opr_cd, @header, %header_data, @row_array, $BREAK, $Oper_Cd, @newrow, $start_time); # This gets the document from the server $f_mfg_desk = '//163.10.50.33/planning/logistics/programs/chicago_wip_ +query.txt'; @header = ("Oper_Cd","Pick_Ref_Num","Part_Id","Lot Qty","Order Id", "Order Lineitem Id","Order Lineline Id","Sublot Num", "Comm Invoice Num","Oper In Dt","Cust Early Shp Dt", "Cust Late Shp Dt","Current Date","Business Class Cd", "Action Expedite Flg","Required Ship Saleable", "Required Ship Inventory Transfer","Total Required Ships"); $start_time = time; open (INFILE, '//163.10.50.33/planning/logistics/programs/chicago_wip_ +query.txt'); while (<INFILE>) { chomp; @newrow = spli t /\t/; $header_data{$newrow[2]} = [$newrow[3..18]]; } close(INFILE)


Once I have this done I then have figured out the email functionality and several other items that I need. The actual manipulation of the document is what eludes me right now. I know I am just at the start, defining the variables and getting the header information read into the program, so I understand I have a long ways to go.

Oh, and I am using Activestate Komodo to write this program in, which is better than a free-ware I was using. Is this the best program for this type of activity, or is there one that is maybe a little more helpful in pointing out where an error is and how to fix it?

Replies are listed 'Best First'.
Re^3: "Global Symbol Requires Explicit Package Name" error
by kutsu (Priest) on Aug 09, 2005 at 22:30 UTC

    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

      Hi Kutsu
      Thank you for the response, I really appreciate the time that you took to respond back. Some answers to your questions:

      I was using Date::Calc to get the current date and compare it to the date that I need to use as a cutoff for rows that I want to delete. If that is in error and I don't need it to do that, then I am fine to drop it.

      The next question, Win32::OLE, I have put that on as a standard to most of my programs, so I have to admit that was out of habit.

      Finally, even with your code, I still get an error uninitialized value in hash element..., and it points me to this section of code in line 29  $header_data{$newrow[2]} = [ $newrow[3..18] ];

      I appreciate the links to the documents, I will print those out and read them. Thank you very much again.
      Portree

        I'd bet you can't open the '//163.../query.txt' file (I don't work with windows much but shouldn't / be \ instead), as that uninitialized value means $newrow[2] has nothing in it (might try a print "@newrow", "\n"; or use Data::Dumper; print Dumper @newrow; to check).

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