Loading ...
Sorry, an error occurred while loading the content.

Re: [PBML] create a file

Expand Messages
  • Damien Carbery
    I ve always thought using die was a bit drastic. I prefer to: if ( ! open( MYFILE, $myfile ) ) { print Error message ; # die ONLY if the program cannot go
    Message 1 of 7 , Jul 31, 2001
    • 0 Attachment
      I've always thought using 'die' was a bit drastic.
      I prefer to:

      if ( ! open( MYFILE, "$myfile ) )
      {
      print "Error message";
      # die ONLY if the program cannot go on
      }
      # Continue program.

      If you are processing multiple files you may be able to print an
      error message and continue, skipping the problem file.

      --- In perl-beginner@y..., jonathansamuel@y... wrote:
      > --- In perl-beginner@y..., "Kai Hintze" <kai_hintze@e...> wrote:
      > > open(FILE, ">$myfile");
      >
      > It is usually a good idea to use the "or die $!" syntax in order to
      > receive a warning when the file cannot be opened. Thus:
      >
      > # Tested on ActiveState 5.6.1/NT4
      > use strict;
      > my $myfile = ">test.txt";
      > open(MYFILE, $myfile) || die $!;
    Your message has been successfully submitted and would be delivered to recipients shortly.