[TriLUG] perl question
William Sutton
william at trilug.org
Sat Mar 14 22:06:51 EDT 2009
I like elegant Perl, but then I'm a Perl programmer by profession. I'm
not sure that I would have chosen to die() if things didn't work, but
knowing that it executed for him, I provided what seemed like a reasonable
solution :-)
William Sutton
On Sat, 14 Mar 2009, Patrick Brewer wrote:
>> I, um, "expect" that this is too late, but
>>
>> eval {
>> $ssh = Expect->spawn("ssh -l $username $ip") || die "didn't work: $!\n";
>> };
>> next if $@;
>>
>> William Sutton
>
> While not as elegant as the above, assuming the above works. I have used the following:
>
> $worked=1;
> <Do something> || $worked=0;
> If (! $worked) {
> <do something else>
> }
>
> die is great for hacked together scripts, but not for something that runs as part of a production service. In that case you want more robust or sophisticated error handling. Or perhaps to retry after a few seconds.
>
> Patrick
>
>
>
>
> --
> TriLUG mailing list : http://www.trilug.org/mailman/listinfo/trilug
> TriLUG FAQ : http://www.trilug.org/wiki/Frequently_Asked_Questions
>
More information about the TriLUG
mailing list