[tpm] IO::Handle not catching errors

James E Keenan jkeen at verizon.net
Mon May 26 16:43:49 PDT 2008


On May 26, 2008, at 3:45 PM, Madison Kelly wrote:
>
>    I use IO::Handle for shell calls,

Why?

When I call 'perldoc IO::Handle', among the first things I read is:

"It is not intended that objects of "IO::Handle" would be created  
directly, but instead "IO::Handle" is inherited from by several other  
classes in the IO hierarchy."

Your example does not suggest that you are inheriting from IO::Handle.

Above and beyond that, you do not appear to be calling it in an  
object-oriented way.  You create the IO::Handle object:

>
> 	print "  Shell call: [$shell_call]\n";

... and then proceed to use it as the second argument to a Perl built- 
in 'open' function, where one would normally expect something like '<':

> 	open ($sc, $shell_call) or die "Shell call: [$shell_call] failed with
> error: $!";

On what basis do you expect the preceding statement to do something  
useful?

You don't appear to call a method on your IO::Handle object until here:


> 	if ($sc->error)
> 	{
> 		die "Shell call: [$shell_call] returned an error: $!";
> 	}
> 	$sc->close;
>

I'm unclear as to what you're intending to do, but I suspect  
IO::Handle is not the way to do it.  Can you clarify?

Thank you very much.
Jim Keenan


More information about the toronto-pm mailing list