in reply to Question about warn statement

I'd probably do something like this:

my $x; open (FILE, ">temp") || do { warn "error message"; $x = 1; };
-- vek --

Replies are listed 'Best First'.
Re: Re: Question about warn statement
by Not_a_Number (Prior) on Aug 22, 2003 at 16:51 UTC

    ...but then $x is still undefined outside the do{} block (which may or may not be a problem).

    my $x; open (FILE, ">temp") || do { warn "error message"; $x = 1; } print "\$x is $x";

    dave

      You're right but (as you mentioned) the fact that $x is undefined may not be a problem at all.

      my $x; open (FILE, ">temp") || do { warn "error message"; $x = 1; }; if ($x) { # so something }
      -- vek --

      Ooops sorry, my bad. Please ignore the above.

      dave