Tie::Handle::CSV



Hi folks.

I've got the following script which works until it reaches the end of the
input file. It processes the last line and prints out the contents, but then
the program terminates with the unhelpful error:

Manufacturers Ref.: L53522 Status: 5290 (Work not pulled)
Comments: ''


at ../bin/walon4 line 25

Line 25 is the last print statement within the while loop. If I delete that
line and re-run the script it then complains about line 24. Either way, the
program terminates before printing 'Hello World'

Anyone got any ideas?

#!/usr/bin/perl -w

use strict;
use warnings;

use Tie::Handle::CSV;
my $csv_fh = Tie::Handle::CSV->new($ARGV[0], header => 1);

while (my $csv_line = <$csv_fh>) {
print "Arrival Date:\t",$csv_line->{"Arrival Date"}, "\t";
print "Chassis:\t",$csv_line->{"Chassis"}, "\t";
print "Walon Ref.:\t",$csv_line->{"Walon Ref."}, "\t";
print "Radio Code:\t",$csv_line->{"Radio Code"}, "\t";
print "Key No.:\t",$csv_line->{"Key No."}, "\n";
print "Inspection 1:\t",$csv_line->{"Inspection 1"}, "\t";
print "Parts Ordered:\t",$csv_line->{"Parts Ordered"}, "\t";
print "Parts Received:\t",$csv_line->{"Parts Received"}, "\n";
print "Estimate Sent:\t",$csv_line->{"Estimate Sent"}, "\t";
print "Authorised:\t",$csv_line->{"Authorised"}, "\t";
print "Repaired:\t",$csv_line->{"Repaired"}, "\n";
print "Manufacturers Ref.:\t",$csv_line->{"Manufacturers Ref."}, "\t";
print "Status:\t",$csv_line->{"Status"}, "\t";
print "(",$csv_line->{"."}, ")\n";
print "Comments:\t'",$csv_line->{"Comments"}, "'\n";
print "\n\n"; # ******* this is line 25 ********
}

print "Hello World\n";
close $csv_fh;
--
Gary Stainburn

This email does not contain private or confidential material as it
may be snooped on by interested government parties for unknown
and undisclosed purposes - Regulation of Investigatory Powers Act, 2000
.



Relevant Pages

  • Re: Auto restart a program
    ... Maybe you can run a script with checks if a .exe is running in task manger to check and if not starting the .exe. ... make the program as a service when the program terminates? ...
    (microsoft.public.windows.server.general)
  • Re: Continuing execution of a script after using exec program from within it.
    ... You need some process alive after the program terminates to log its' ... So, don't use exec, do something like: ... or, write one of the above into a script file, and exec the script file. ...
    (comp.unix.shell)
  • Re: A script to flag commonly misused words
    ... is preferable in general as it allows you to scope warnings. ... use strict; ... I first wrote a script to extract the words to flag from your ... I discovered that at least one of the expressions you ...
    (comp.lang.perl.misc)
  • Re: Really Baffled any clues as to what is going on?
    ... > I am working on a script, it has an input file of machine names. ... > Dim fstrLogFilePath ... > fstrInputFile = InputBox("Enter name of file containing machines to ...
    (microsoft.public.scripting.vbscript)
  • Re: Parse an input file using a Key value
    ... I have an input file in the following format getting repeated. ... I tried to achieve this task using the following script below but it is ... To tranpose certain rows into columns and sort by one of the ...
    (comp.unix.shell)