Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: Reading output of external program without Shell

by karlgoethebier (Abbot)
on Nov 15, 2017 at 16:03 UTC ( [id://1203488]=note: print w/replies, xml ) Need Help??


in reply to Reading output of external program without Shell

Apropos pdftotext. What about CAM::PDF to extract the text? As far as i remember it comes with such a feature. Regards, Karl

Update: Just found an example on my box. I didn't remember that it is so simple:

#!/usr/bin/env perl use strict; use warnings; use CAM::PDF; use feature qw(say); my $file = shift; my $pdf = CAM::PDF->new($file); say $pdf->getPageText(1); __END__

«The Crux of the Biscuit is the Apostrophe»

perl -MCrypt::CBC -E 'say Crypt::CBC->new(-key=>'kgb',-cipher=>"Blowfish")->decrypt_hex($ENV{KARL});'Help

Replies are listed 'Best First'.
Re^2: Reading output of external program without Shell
by Anonymous Monk on Nov 15, 2017 at 18:27 UTC

    Hi karlgoethebier. I tried in the past CAM::PDF; . In the future I may opt for it, but at the moment I think the quality of output of pdftotext (from xpdf) is unbeatable (but I'll run some more tests)

      Thanks for your kind reply. BTW, as far as i vaguely remember this doesn't call a shell:

      #!/usr/bin/env perl use strict; use warnings; use IPC::Run qw( run ); use feature qw(say); my $command = q(cat); my $text = run qq($command $0); say $text; __END__

      Best regards, Karl

      «The Crux of the Biscuit is the Apostrophe»

      perl -MCrypt::CBC -E 'say Crypt::CBC->new(-key=>'kgb',-cipher=>"Blowfish")->decrypt_hex($ENV{KARL});'Help

        this doesn't call a shell

        The code you showed does, but if you give run an arrayref, it does not (at least on *NIX):

        $ perl -wMstrict -MIPC::Run=run -e' run "pstree -A $$" ' perl---sh---pstree $ perl -wMstrict -MIPC::Run=run -e' run ["pstree","-A",$$] ' perl---pstree

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1203488]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (4)
As of 2024-04-18 05:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found