Personally, I'd do it the other way around, that is, just write the whole thing in Perl... but ok, embedding Perl into a longer shell script is ok too, I guess... ;-)
I'm assuming you're using bash, and you don't seem to need STDIN in your Perl script, so I'd probably use a here doc, like in the following. I've also made some tweaks, plus you didn't seem to be passing the Perl script any filenames. (Note: I tested without RTF::TEXT::Converter.)
function fConvert {
perl -wMstrict -- - $@ <<'ENDPERL'
use RTF::TEXT::Converter;
my $result = '';
my $object = RTF::TEXT::Converter->new( output => \$result );
foreach my $filename (@ARGV) {
$object->parse_stream($filename);
print $result;
$result = '';
}
ENDPERL
}
Update: Or, just make it a oneliner ;-) (the module just prints its output by default)
perl -wMstrict -MRTF::TEXT::Converter -00ne
'RTF::TEXT::Converter->new->parse_string($_)'
Update 2: I guess I should mention why I'd suggest a heredoc: when the delimiter is quoted (as in 'ENDPERL'), you don't have to worry about special characters within the heredoc. |