printing from an IO handle _to_ an IO handle 
Author Message
 printing from an IO handle _to_ an IO handle

I was wondering why I get a syntax error in this:

===========================
use IO::File;

my $s = new IO::File('/dev/null') or die "No file!" ;
my $t = new IO::File('>/dev/null') or die "No file!" ;
print $t <$s> ;
============================
syntax error near "$s>"

This with perl 5.004.  It apparently has to do with having *two* IO
handles in the print statement --- either print $t ARRAY or print
HANDLE <$s> both work, but I can't do the IOhandle->IOhandle copy in
one step this way, as far as I can figure...

  /Bernie\
--

Roanoke Electronic Village



Mon, 01 Mar 2004 20:15:49 GMT  
 printing from an IO handle _to_ an IO handle


Quote:
>I was wondering why I get a syntax error in this:

>===========================
>use IO::File;

>my $s = new IO::File('/dev/null') or die "No file!" ;
>my $t = new IO::File('>/dev/null') or die "No file!" ;
>print $t <$s> ;
>============================
>syntax error near "$s>"

Indirect object notation is confusing the DWIMer in perl.
Try

    $t->print(<$s>);

Quote:
>This with perl 5.004.  It apparently has to do with having *two* IO

You should consider upgrading your perl to 5.6.1.

--
    This space intentionally left blank



Mon, 01 Mar 2004 20:26:47 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Fix for ioctl in IO::Handle (and IO::File)

2. FileHandle vs IO::Handle

3. writing to a io handle using open2

4. Redhat 8.0: IO::Handle::setvbuf not implemented on this architecture

5. Can't get IO::Handle to work

6. destroying IO::Handle without close()ing the file

7. problem with IO::Handle

8. IO::Handle::setvbuf not implemented on this architecture.

9. Like to use an IO::Tee handle for Digest::SHA1

10. Inherriting from IO::Handle

11. IO::Handle question about non-blocking mode

12. How to use IO::Handle to open a pipe

 

 
Powered by phpBB® Forum Software