in reply to Copy multiple lines to a loop
#!/usr/bin/perl -w use strict; use Glib qw(TRUE FALSE); $|++; print "Enter multi-lines, and finish with Control-d\n"; my $main_loop = Glib::MainLoop->new; #my $watcher; #$watcher = Glib::IO->add_watch( fileno( $pty ), ['in', 'hup'], \&call +back); Glib::IO->add_watch (fileno 'STDIN', [qw/in/], \&watch_callback, 'STDI +N'); $main_loop->run; sub watch_callback { # print "@_\n"; my ($fd, $condition, $fh) = @_; my (@lines) = (<STDIN>); print @lines; #always return TRUE to continue the callback return TRUE; }
|
|---|