467,882 Members | 1,218 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 467,882 developers. It's quick & easy.

chdir doubt

Hi,

I am using a command as below in my script to change the directory. If the $dir is not available, the program dies.
I want to add some more functionality. For example, I want to send a mail before it dies. How do I do it? I know how to send e-mail but want to know how the existing code canbe changed in order to handle? Before or die in the code? Thanks.

Expand|Select|Wrap|Line Numbers
  1. chdir($dir) or die "Can't chdir to $dir ! \n";
Aug 18 '08 #1
  • viewed: 1041
Share:
2 Replies
KevinADC
Expert 2GB
Expand|Select|Wrap|Line Numbers
  1. chdir($dir) or send_an_email($!);
  2.  
  3. sub send_an_email {
  4.    my $error = $_[0];
  5.  
  6.    # here you send the email however you want
  7.    # include $error in the email 
  8.  
  9.    exit(0);
  10. }
Aug 18 '08 #2
ok many thanks for your response.
Aug 20 '08 #3

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

reply views Thread by Andrew Crowe | last post: by
5 posts views Thread by Nicholas Geraldi | last post: by
reply views Thread by Jon Schull | last post: by
4 posts views Thread by Yun Mao | last post: by
reply views Thread by Tom McDavid | last post: by
3 posts views Thread by dannycolligan | last post: by
5 posts views Thread by HMS Surprise | last post: by
reply views Thread by Julien Biezemans | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.