in reply to File open problem with "GLOB"
my $output = new OUTFILE ('>C:\Program Files\cron\Cruise Ships\ship_da +ta.csv');
Not exactly sure* why you get the specific error you are getting, but that statement is both wrong and the cause. That statement is suppose to mean
my $output = OUTFILE->new('>C:\Program Files\cron\Cruise Ships\ship_da +ta.csv');
which isn't what you want at all. You want
open(my $output, '>', 'C:\\Program Files\\cron\\Cruise Ships\\ship_dat +a.csv');
But now you have two file handles to the same file (OUTFILE and $output). Use
Or better yet, don't use global variables:use IO::Handle qw( ); ... my $out_fn = 'C:\\Program Files\\cron\\Cruise Ships\\ship_data.csv'; open(OUTFILE, '>', $out_fn) or die("Unable to create output file \"$out_fn\": $!\n"); ... print (OUTFILE $input); ... OUTFILE->print ( join(',', @$row), "\n");
my $out_fn = 'C:\\Program Files\\cron\\Cruise Ships\\ship_data.csv'; open(my $out_fh, '>', $out_fn) or die("Unable to create output file \"$out_fn\": $!\n"); ... print ($out_fh $input); ... $out_fh->print ( join(',', @$row), "\n");
Of course, using two different ways of calling print is confusing. You should stick to the one you like.
Note I added error checking to open. If anything's going to fail when you run the program, that's going to be it.
* — It's a mixture of indirect method requiring guesswork on Perl's part, barewords often represent file handles, and file handles are blessed as IO::Handle objects by default.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: File open problem with "GLOB"
by mcoblentz (Scribe) on Mar 16, 2008 at 06:36 UTC |