Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
Hi Guys,
I found out something that might help. Try this code out.

#!/usr/bin/perl -w use strict; use Gtk2 '-init'; use Gtk2::Helper; use Data::Dumper; use IPC::Open2; use FileHandle; # file handles my $wfh = FileHandle->new(); my $rfh = FileHandle->new(); open2($rfh,$wfh, "C:\\Windows\\System32\\cmd.exe"); my $window = Gtk2::Window->new(); $window->signal_connect("destroy",sub{Gtk2->main_quit();}); $window->set_size_request(200,200); my $vbox = Gtk2::VBox->new(); $window->add($vbox); my $button = Gtk2::Button->new("WRITE"); $button->signal_connect('clicked'=>sub{ write_fh(); }); $vbox->pack_start($button,0,0,0); $button = Gtk2::Button->new("READ"); $button->signal_connect('clicked'=>sub{ read_fh(); }); $vbox->pack_start($button,0,0,0); $window->show_all(); Gtk2->main(); sub write_fh { print $wfh "dir\n"; } sub read_fh { my $buffer; my $resp = sysread($rfh,$buffer,1); if($resp){ if($buffer =~ /\n/){ print "newline\n"; } } print "[$resp]$buffer\n"; }

Run the program and press the read button until it hangs, it always hangs when it encounters the "end of file" but i think its not the end of file because I am reading the output of the command line. I tried using eof($rfh) and it hangs hehehe... Help please

Mabuhay Civil Engineers! :D

In reply to Re: ActivePerl Gtk2::Helper Hangs by renegadex
in thread ActivePerl Gtk2::Helper Hangs by renegadex

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or or How to display code and escape characters are good places to start.
Log In?

What's my password?
Create A New User
Domain Nodelet?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (2)
As of 2022-08-09 04:47 GMT
Find Nodes?
    Voting Booth?

    No recent polls found