in reply to wierd output

Start by reading perlintro and Coping with Scoping and write subs like this

sub cheat { my( $cheatfile ) = @_; open my($info), '<', $cheatfile or die "Can't open( $cheatfile ): +$!"; while(<$info>){ print $_; } close $info; }

and use it like

cheat( "/home/cheatsheets/$prefix.txt" );

If you want help with that $session stuff, you'll have to explain what that is (How do I post a question effectively? ) although it could be buffering, terminal ansi escapes, or just something else.

in case of buffering :) Tutorials: Input and Output: Suffering from Buffering?

Replies are listed 'Best First'.
Re^2: wierd output
by Anonymous Monk on Dec 17, 2012 at 12:58 UTC

    FWIW, a smarter way would be

    cheat( "/home/cheatsheets/$prefix.txt" , \*STDOUT ); sub cheat { my( $cheatfile, $outhandle ) = @_; open my($info), '<', $cheatfile or die "Can't open( $cheatfile ): +$!"; while(<$info>){ print $outhandle $_; } close $info; }

    But if you're going to write that you might as well use File::Copy::copy :)

    use File::Copy qw' copy '; copy( "/home/cheatsheets/$prefix.txt" , \*STDOUT );

    This assuming you're only copy-ing verbatim