diff options
Diffstat (limited to 'lib/HTML/AutoConvert/Run.pm')
-rw-r--r-- | lib/HTML/AutoConvert/Run.pm | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/lib/HTML/AutoConvert/Run.pm b/lib/HTML/AutoConvert/Run.pm new file mode 100644 index 0000000..2eada89 --- /dev/null +++ b/lib/HTML/AutoConvert/Run.pm @@ -0,0 +1,30 @@ +package HTML::AutoConvert::Run; + +=head1 NAME + +HTML::AutoConvert::Run - Base class for HTML::AutoConvert plugs that run an external program + +=cut + +use strict; +use IPC::Run qw( run timeout ); + +sub html_convert { + my( $self, $file ) = ( shift, shift ); + my $opt = ref($_[0]) ? shift : { @_ }; + + my @program = $self->program; + my $program = $program[0]; + + my $timeout = 60; #? + + my( $html, $err ) = ( '', ''); + local($SIG{CHLD}) = sub {}; + run( [ @program, $file ], \undef, \$html, \$err, timeout($timeout) ) + or die "$program failed with exit status ". ( $? >> 8 ). ": $err\n"; + + $html; + +} + +1; |