in reply to "Global Symbol Requires Explicit Package Name" error

For a better explanations of error messages, you can look them up in perldiag ('perldoc perldiag'), or simply use diagnostics; to get the explanation automatically
Global symbol ``%s'' requires explicit package name

    (F) You've said ``use strict vars'', which indicates that
    all variables must either be lexically scoped (using ``my''),
    declared beforehand using ``our'', or explicitly qualified to
    say which package the global variable is in (using ``::'').

MJD says "you can't just make shit up and expect the computer to know what you mean, retardo!"
I run a Win32 PPM repository for perl 5.6.x and 5.8.x -- I take requests (README).
** The third rule of perl club is a statement of fact: pod is sexy.

Replies are listed 'Best First'.
Re^2: "Global Symbol Requires Explicit Package Name" error
by Portree (Novice) on Aug 10, 2005 at 16:21 UTC
    Hello All,
    Thank you very much for taking the time to reply. I linked to those documents and I will read them over, I have even printed some of them. So, am I to understand that this is some kind of text string error? Thank you all again

    Portree
      Hello All
      OK a few questions to help me understand. In my code below (as is familiar already) I have sections of the code that I have used, but I am really not quite sure what they do. I have played around with it and if someone could help me to understand better I would appreciate it.

      I have buried my questions in the code below, removing all comments that were there already, that way my questions are clear. Thanks again for the help

      Portree
      use strict; use warnings; #good! use Win32::OLE; use Date::Calc; use diagnostics; my %header_data; my $f_mfg_desk = '//163.10.50.33/planning/logistics/programs/chicago_w +ip_query2.txt'; my $f_mfg_desk2 = '//163.10.50.33/planning/logistics/programs/chicago_ +wip_query3.txt'; my ($sec, $min, $hour, $dayofmonth, $month, $year, $weekday, $day) = l +ocaltime(time); $month++; $year += 1900; open (INFILE, $f_mfg_desk); ($record);... or while (<INFILE>) { chomp; my @newrow = split /\t/; # What does this below statement acutally mean? $header_data{$newrow[2]} = [ $newrow[3..18] ]; } close(INFILE); open (OUTFILE, ">$f_mfg_desk2"); # If I am sorting by this data, why does it delelte most of # the data +? # Which data field is actually being used to sort? for my $key (sort keys %header_data) { for my $a (@{$header_data{$key}}) { print OUTFILE "$a\t"; } print OUTFILE "\n"; }
        # What does this below statement acutally mean? $header_data{$newrow[2]} = [ $newrow[3..18] ];

        You are creating an array of the 4th through 19th elements of the @newrow array and associating it to the 3rd element of @newrow in the %header_data hash array (i.e. you are using the 3rd element as a key and setting the value to a reference to an array of the 4th through 19th elements -- remember arrays start at index zero).

        If there are duplicates of the 3rd elements in the data, then only the last row will be saved (maybe that's why you're "losing data"?).

        # Which data field is actually being used to sort? for my $key (sort keys %header_data)
        Each 3rd element that came from @newrow above.
        Hi Kutsu

        I couldn't reply on your thread so I thought I would just add to this one. I can actually open the file, so that is not a problem. The problem is totally in my lack of understanding on how the process works and gettng a bit of information here and there. I am a visual basic programmer, so Perl is very new to me and doesn't always seem as logical.

        For instance, these are the values that are at the top row of my tab delimited file (if you think of it as an Excel spreadsheet this is line one):

        "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"

        I want to sort the data on the file by "Cust Late Shp Dt" (Bold Highlight). Then I want to eliminate all rows of data where the the date is greater than today's date (such as tomorrow or the next day). In VB this is a very easy task, but this alludes me in Perl.

        I have read the document on sorting, but to me it is not clear as to what is the proper code to use to sort by one segment of a header file. If someone could please explain this in plain english (I know, I am still learning the jargon of Perl) then I would be extremely grateful.

        Portree
        Hi runrig,
        Thanks for stoping by. If you don't mind, could I ask another question. You have said that you understand why I am loosing data. How do I prevent this? How do I take a header element and just sort by it without loosing my data? I have read all of the documentation that I can get my hands on but I just can't get it to work. I need to delete whole rows with certain data, and then sort the rest. Can you assist?

        Regards
        Portree