Hi ppl,

Got a really weird problem, which comes and goes but is upsetting my perl output.

Code snippet
sub cheat { my $cheatfile = "/home/cheatsheets/$prefix.txt"; open( INFO, $cheatfile ); @lines = <INFO>; close(INFO); foreach (@lines){ print $_; } }
##above stores and prints file contents to screen
my $counter = 0; while($counter <= 1){ $session->exp->interact(\*STDIN,"\cA"); my $exit = qx(cat $showlog); if ($exit =~ /exit|quit|logout|Inactivity/){ print colored("logfile:$showlog\n",'yellow'); die; ++$counter; } &cheat; $session->exp->send("\r\n"); }

#the above hands session to user..... and loops until it finds an exit|logout or quit in the logfile then quits
#in the meantime whilst in interact mode the user can press cntrl + a and it prints the files contents by calling the subroutine.

This all works fine... however the output of the file changes

correct output

networks> adslc -s -s 1________________________line status [card mode] adslc -s -e 1________________________line errors [card mode] networks>

incorrect output

networks> adslc -s -s 1________________________line status [card mode] adslc -s - +e 1________________________line errors [card mode] networks>

i can press cntrl + a any number of times and randomly the output will distort from the normal format like above.

Anyone know a possible cause? Tried all kinds of workarounds and come to the conclusion that anytime a "\n" is used in the loop, this distortion occurs every so often. The next line in the file prints at the end of the previous line but on a newline, if that makes sense :s

i.e. line1 line2 line3

Would be very greatful for the help


In reply to wierd output by oldirtysingh

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.