[Chicago-talk] Strange file creation

Andy Lester andy at petdance.com
Thu Oct 5 11:30:58 PDT 2006


On Oct 5, 2006, at 1:27 PM, Eric Ellington wrote:

> sub makefile
>   {
>     my($date, $fn, @info) = @_;
>     my $filename = $fn . $date . '.csv';
>     print $filename,"\n";
>
>     open(OUT,'>'.$filename) ||
>       die "COULD NOT OPEN $filename FOR OUTPUT ";
>
>     print(OUT "\n");
>     print(OUT @info);
>
>     close(OUT);
>   }

Well, we need to see how @info is getting filled then.

I would also suggest rewriting this as:

sub makefile {
     my ($date,$fn, at info) = @_;
     my $filename = "$fn$date.csv";
     print "Writing to $filename\n";
     open( my $out, '>', $filename ) or die "Can't open $filename: $! 
\n";
     print $out "\n";
     print $out @info;
     close $out;
}

But let's see how you're putting stuff into @info.  That's the real  
issue here.  Perhaps you have a heredoc improperly closed?

--
Andy Lester => andy at petdance.com => www.petdance.com => AIM:petdance






More information about the Chicago-talk mailing list