> It looks like 99% of the code in both blocks is exactly the same. You > should > factor out duplicated code. > > my $msg = $backup ? 'failed' : 'completed'; > > my %mails = ( > To => $to, > From => $from, > Subject => "Remote backup $msg from $ENV{HOSTNAME} on $time", > Message => "The remote backup has $msg on $ENV{HOSTNAME} on $time > with > the command:\n\n $rdiff @args\n" > ); > sendmail( %mails ); > # finish message > print "\n", $separator, "Remote backup $msg on $time. E-mail sent with > details.\n", $separator; >
Thanks John and Chris. Chris, I have gone for John method of using the $seperator, as I will use that more in this script when I add more features, thanks for the pointer on here documents though. I have taken on board all your suggestions, but I still have two questions: 1. How does the above code get the return code from rdiff to tell if it failed or passed? Is this the $backup ? part, i.e. failed first, then completed second? 2. use POSIX qw(strftime); I got this from Perl Cookbook. I take it this is calling the POSIX strftime and putting it in a list, so when I select %T etc. it is picking it from the list? Why does it fail if I put use POSIX; and put qw(strftime); somewhere else. Oh, and I have the bug now :-) It's a great felling when your script works!!! You will be seeing much more of my code in here, so hopefully I will be learning and not pasting the same mistakes. P.S. I am now a programmer or a scripter, I am not sure is perl is programming or scripting? I think programming. Gavin. Would anyone actually like a [EMAIL PROTECTED] e-mail address? -- Just getting into the best language ever... Fancy a [EMAIL PROTECTED] Just ask!!! -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>