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

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



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.