in reply to Perl script comes out because of a command failure. How to overcome it?

G'day Sharath,

I'd recommend starting by cleaning up your code. I don't know if you've shown everything here: there's a few things that could potentially cause problems that can easily be avoided. Here's some suggestions:

Your current code:

my $req; while ($req = ...

would probably be better as:

while (my $req = ...

And I suspect:

chomp;

is supposed to be:

chomp $req;

Once you've done that, it's possible your current problems may be resolved (I'm unfamiliar with this adb program you mention, so I don't really know). However, assuming that's not the case, look at eval for a way to trap errors: you'll want the block form of eval which you'd code something like this:

eval { # Code which might generate an error } if ($@) { # Handles any errors here # $@ holds the error message }

-- Ken

Replies are listed 'Best First'.
Re^2: Perl script comes out because of a command failure. How to overcome it?
by ramki067 (Acolyte) on Nov 05, 2013 at 08:58 UTC
    Thanks kcott and Ken. The problem resolved once i added $t->errmode("return"); suggested by Kcott before while statement. I have even added chomp $req what Ken suggested. Thanks again for the solving my 1 week headache. Cheers, Sharath

      You seem a little confused over who's who and who posted what.

      kcott and Ken are one and the same (i.e. me); just as ramki067 and Sharath are one and the same (i.e. you).

      It was Athanasius who suggested $t->errmode("return");. He won't be notified of your reply to me; you may want to thank him separately.

      Anyway, glad you've resolved your problem, regardless of who's advice was involved. :-)

      -- Ken