[Wylug-help] perl and Tie::Handle::CSV

Imran Javeed imran.javeed at i-ksolutions.com
Thu Jun 28 00:47:43 BST 2007


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:
@@@@@@@@@@@@@@@@@@@

Gary

This line doesn't look right to me

print "Comments:\t'",$csv_line->{"Comments"}, "'\n";

Regards

Imran
Regards

Imran Javeed


-----Original Message-----
From: Gary Stainburn <gary.stainburn at ringways.co.uk>
Date: Wed, 27 Jun 2007 17:34:58 
To:wylug-help at wylug.org.uk
Subject: [Wylug-help] perl and 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     

_______________________________________________
Wylug-help mailing list
Wylug-help at wylug.org.uk
https://mailman.lug.org.uk/mailman/listinfo/wylug-help


More information about the Wylug-help mailing list