From: Doug Laidlaw on
I have a Perl script (pcal) which prints to standard output. I didn't write
it.

The relevant line is $THECAL=`....'; print $THECAL;

I want to modify this line to print to the default (local) printer on lpr.
How do I go about this?

TIA,

Doug.
--
Books are good enough in their own way; but they are
a mighty bloodless substitute for life.
-R.L. Stevenson.

From: Sherm Pendley on
Doug Laidlaw <laidlaws(a)dougshost.invalid> writes:

> I have a Perl script (pcal) which prints to standard output. I didn't write
> it.
>
> The relevant line is $THECAL=`....'; print $THECAL;
>
> I want to modify this line to print to the default (local) printer on lpr.
> How do I go about this?

Open a pipe to lpr and select it:

my $THECAL = '....';
open my $lpr, '|-', '/usr/bin/lpr'
or die "Could not open lpr pipe: $!";
select $lpr;
print $THECAL;

For details:

perldoc -f select
perldoc -f open

If you want to make only one or two prints go to lpr, instead of all of
them, you can specify the filehandle in the print:

print $lpr $THECAL;

sherm--

--
Web Hosting by West Virginians, for West Virginians: http://wv-www.net
Cocoa programming in Perl: http://camelbones.sourceforge.net