in reply to still confused!

You need to give a little more information. What kinds of error messages are you getting? What does the output look like?

Here are some suggestions, though:

When you open files, always use error handling:
open (FILE, "file.txt") or die "Can't open file: $!";

You are wasting a ton of memory by loading the files into arrays completely. instead, use a loop like this:
while (<FILE>) { #put stuff in the hash here }
Then, as soon as you are done with a file, it is good practice to close it.

Those lines that define the keyhash aren't doing what you expect. They are just adding erroneous elements to keyhash. Perl will automatically add whatever you tell it to, there's no need to tell it what to expect.

Don't use for to loop through an array. Use foreach. While for will work the same most of the time, it can bite you.

You should probably read the perlref and perllol man pages to learn how to use complex data structures. While you're almost there, you make some errors. For example,
$hashref{$_}{CSV}; should be ${$hashref{$_}}{CSV};
I know this can get confusing, I've messed it up plenty of times myself.



When's the last time you used duct tape on a duct? --Larry Wall

Replies are listed 'Best First'.
Re: Re: still confused!
by Albannach (Monsignor) on Mar 24, 2001 at 02:53 UTC
    Actually for and foreach really are identical, though the latter looks better in this case.

    --
    I'd like to be able to assign to an luser

Re: Re: still confused!
by Anonymous Monk on Mar 24, 2001 at 02:55 UTC
    I made the modifications as you suggested. I'm getting the following errors.

    Global symbol "@data" requires explicit package name at ./billing.pl l +ine 16. Global symbol "@data2" requires explicit package name at ./billing.pl +line 17. Global symbol "$id" requires explicit package name at ./billing.pl lin +e 21. Global symbol "$name" requires explicit package name at ./billing.pl l +ine 21. Global symbol "$srid" requires explicit package name at ./billing.pl l +ine 22. Global symbol "@data" requires explicit package name at ./billing.pl l +ine 29. Global symbol "@data2" requires explicit package name at ./billing.pl +line 48. Execution of ./billing.pl aborted due to compilation errors.


    But the script still isn't in shape enough to do what I need it to do, right?!
      Actually I fixed that mess. Now when I run the script, I get the following:

      No such record ZZ!
      No such record ZZ!
      No such record ZZ!
      No such record ZZ!
      No such record ZZ!
      No such record ZZ!
      No such record ZZ!
      No such record ZZ!
      No such record ZZ!
      No such record ZZ!
      No such record ZZ!
      No such record ZZ!
      No such record ZZ!
      No such record ZZ!
      No such record ZZ!
      No such record ZZ!
      No such record ZZ!
      No such record ZZ!
      No such record ZZ!
      No such record ZZ!
      No such record ZZ!
      No such record ZZ!
      No such record ZZ!
      No such record ZZ!

      The script is reading the wrong field..ZZ is being pulled from the first field, I need the second field to be looked at. Also, it looks as if it's looping through over and over. Any suggestions?

      Thanks.
        It looks like you are making progress. You have made enough changes that it would be good if you'd post your code as it now stands so we can see where you are.