Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > How to print to more than one output

Reply
Thread Tools

How to print to more than one output

 
 
Bern
Guest
Posts: n/a
 
      07-26-2004
Hello list,

Is it possible to print to two different output at once?

For example, I tried the following but it does not work. Nothing shows
up in the log file.

open(LOG, ">test.log") or die "Can't create log file: $!";
print { LOG && STDOUT } `ls -l`;

Thanks,
Bern
 
Reply With Quote
 
 
 
 
510046470588-0001@t-online.de
Guest
Posts: n/a
 
      07-26-2004
(Bern) writes:


> Is it possible to print to two different output at once?



one may exec the tee command and pipe into it.


Klaus Schilling
 
Reply With Quote
 
 
 
 
Anno Siegel
Guest
Posts: n/a
 
      07-26-2004
Jim Gibson <> wrote in comp.lang.perl.misc:
> In article < >, Bern
> <> wrote:
>
> > Hello list,
> >
> > Is it possible to print to two different output at once?

>
> Not in a single print statement, no. There isn't the Perl equivalent of
> the Unix tee command.
>
> >
> > For example, I tried the following but it does not work. Nothing shows
> > up in the log file.
> >
> > open(LOG, ">test.log") or die "Can't create log file: $!";
> > print { LOG && STDOUT } `ls -l`;

>
> This will print to STDOUT only, because the block returns the value of
> the STDOUT file handle, following the rules of the logical and
> operator. The LOG file handle is evaluated first, and, because it is
> true, the STDOUT is evaluated next and returned as the value of the
> expression.
>
> You will have to write your own subroutine to output to two or file
> handles.


The IO::Tee module on CPAN also handles this.

Anno
 
Reply With Quote
 
Brian McCauley
Guest
Posts: n/a
 
      07-27-2004
(Bern) writes:

> Subject: Re: How to print to more than one output
>
> Is it possible to print to two different output at once?


This is FAQ: How do I print to more than one file at once?

Please consult the FAQ _before_ posting a question.

Note the there are two answers to this (the ones you've been given
already) and oddly older versions of the FAQ give one and newer
versions the other.

--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
Can one declare more than one signal on one line? Merciadri Luca VHDL 4 11-01-2010 02:00 PM
Like all great travelers, I have seen more than I remember andremember more than I have seen. shenrilaa@gmail.com C++ 0 03-05-2008 08:41 AM
Like all great travelers, I have seen more than I remember andremember more than I have seen. shenrilaa@gmail.com C Programming 0 03-05-2008 03:26 AM
Problem - I want to print Current Output of Pdf file and should print once.I get print dialog box but it is not working keto Java 0 05-30-2007 11:27 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57