Hi everyone. It's my first post here so hope I get it right :)
Short background to the problem:
I'm using Net::Telnet module for a program and want to log the traffic on the telnetport. Telnet-module has a function for writing IO-traffic to a filehandle.
I like to view that traffic as the program runs and I've done that with the modules IO::String or IO::Scalar (in IO::Stringy). IO::String emulate file interface for in-core strings. Telnet-traffic is saved to a variable $var so I can process it. Now to the problem.
Problem:
I'm using threads for updating $var (the traffic) to screen as the program runs. But the threads-module don't go along with IO::String or IO::Stringy, but I read that it should. I get the compile message:
Attempt to free unreferenced scalar: SV 0x1c335fc during global destruction.
If you don't know any solution to what causes that warning, is there another way to do what I described above?
I think using threads is the way because I dont want to stop telnet-command-execution each time I update screen with new Telnet-traffic messages. Anyway, I have scaled down the code that gives the error to almost nothing.
Here it goes. (runs on Active State Perl 5.8.3)
#!/usr/bin/perl -w use strict; use threads; use IO::String; my $var; # This variable is later connected to IO-stream. my $io = IO::String->new($var); # connect $var to IO-stream. my $th=threads->new(\&Update); # start thread $th->join(); # collect thread sub Update{}; #Updating screen with $var. # $io: Used as a filehandle for logging in Net::Telnet module. # $var stores all that prints to $io.
Hope this was not to long to read. I appreciate all the help or guidelines I can get, thanks!

In reply to Problem with using threads with modules. by tele2mag

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.