On 11-04-15 11:22 AM, sono...@fannullone.us wrote:
open ('FILEOUT', '>>', 'cmdout') ||die "cant open cmdout: $! \n";

        Is that O.K.?

The problem with not using lexical-scoped file handles is that if a module opens a file using the same name, it closes yours. It's best if you limit the scope of the file handle to the block of the open. You can always pass the file handle to a subroutine:

sub foo {
  my $fh = shift @_;

  print $fh "Foo\n";
}

my $file = 'foo.tmp';
open my $out_fh, '>', $file or die "could not open $file: $!\n";

foo( $out_fh );

close $out_fh '>', $file or die "could not close $file: $!\n";


--
Just my 0.00000002 million dollars worth,
  Shawn

Confusion is the first step of understanding.

Programming is as much about organization and communication
as it is about coding.

The secret to great software:  Fail early & often.

Eliminate software piracy:  use only FLOSS.

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to