Re: Event->io does not accept GLOB refs

[email protected] (Jochen Stenzel)
Newsgroups perl.loop
Message-ID <[email protected]>
Hello, Marc,

this works:

- snip --

use Event;

die "Usage: $0 <filename>\n" unless @ARGV and -e $ARGV[0];

my $fh = do { local *GLOB };
open $fh, "<", $ARGV[0] or die $!;

print "fileno: ", fileno $fh, "\n";
print "asstring: $fh\n";

# here is the difference
Event->io(fd=>\$fh, cb=>\&callback);

Event::loop;

# demo callback
sub callback
 {
  my ($event)=@_;
  my $ifh=$event->w->fd;

  my $line=<$ifh>;
  print $line;

  Event::unloop if eof($ifh);
 }

- snip --

Greetings

                Jochen
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.