oldirtysingh has asked for the wisdom of the Perl Monks concerning the following question:
Got a really weird problem, which comes and goes but is upsetting my perl output.
Code snippet##above stores and prints file contents to screensub cheat { my $cheatfile = "/home/cheatsheets/$prefix.txt"; open( INFO, $cheatfile ); @lines = <INFO>; close(INFO); foreach (@lines){ print $_; } }
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.
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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: wierd output
by oldirtysingh (Novice) on Dec 17, 2012 at 13:43 UTC | |
|
Re: wierd output
by Anonymous Monk on Dec 17, 2012 at 12:53 UTC | |
by Anonymous Monk on Dec 17, 2012 at 12:58 UTC | |
|
Re: wierd output
by oldirtysingh (Novice) on Dec 17, 2012 at 14:15 UTC | |
by BillKSmith (Monsignor) on Dec 17, 2012 at 14:30 UTC | |
|
Re: wierd output
by aitap (Curate) on Dec 17, 2012 at 16:24 UTC |