The problem is with
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

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");
Or better yet, don't use global variables:
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.


In reply to Re: File open problem with "GLOB" by ikegami
in thread File open problem with "GLOB" by mcoblentz

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.