On 26/07/2011 16:39, Nikolaus Brandt wrote:
On Tue, Jul 26, 2011 at 01:01:54PM +0300, Shlomi Fish wrote:

Another option would be to use eval { ... } and $@ to trap exceptions:

Thank you all for the replies.

I used the above mentioned eval-$@ solution which was absolutely  working fine.

I think Shlomi may have been over-thorough in his list of options. Most
Perl programmers would shudder at the sight of an eval, and in this case
it is an ugly implementation of the try/catch idiom.

John's

open my $fh, '>', "$basedir/$userdir/$outfile" or do {
  warn "Can't write: $!\n";
  return;
};

(With or without the warning) will do all that you want, and will
enamour you to all who read your code.

Rob




--
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