Thanks BrowserUk

I thought that by closing the handler it will automatically end the child process, but I ended up the other way around, I killed the child process an I don't even need to close the handle, this is how I worked out:

#!/usr/bin/perl $SIG{INT} = \&end; my $kid = open (TELNET, '-|', "telnet 192.168.1.1 6088"); while(<TELNET>) { $arr = <TELNET>; $arr =~ s/[\r\n](.....):(.*)/<p class="$1">$1:$2<\/p>/; print $arr; } end; sub end { kill 9, $kid; ## Or whatever signal is appropriate! print "Session closed!\n" exit; }

But actually I am moving forward now, this version didn't work on Active Perl, I am looking for something that would support as much platforms as I can.

Now instead of use the pipe I use the IO::Socket::INET library with the recv subroutine, but since it is lower level I am having some troubles parsing the lines :P.

Anyways thanks for the help, now this script is helping me a lot for my work.

gmoque


In reply to Re^2: How do I close a pipe by gmoque
in thread How do I close a pipe by gmoque

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.