develooper Front page | perl.beginners | Postings from February 2009

Exception Handling in perl

Thread Next
From:
Sarsamkar, Paryushan
Date:
February 27, 2009 05:42
Subject:
Exception Handling in perl
Message ID:
58D439F76B2B6B4888EE8E8D9CB8D2110D334620@HQ-MAIL3.ptcnet.ptc.com
Hi All,

 

Can we handle exceptions in PERL programs?

 

For example - Here if it fails to copy then can I handle the exception
and perform the next steps in my script? I tried removing "die" but then
it does not complain and I wont be able to come to know if that is
copied or not. (Is there anything similar to try and catch as in JAVA?) 

 

----code----

#!/usr/bin/perl

use strict;

use warnings;

use File::Copy;

 

copy ("C:\\build.xml","D:\\build.xml") or die "Cannot copy : $!";

 

#next things to do

 

----code-----

 

Thanks,

Paryushan

 


Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About