in reply to Re: Trash in my prints
in thread Trash in my prints

Try it like this:

{ local $\; print '1'; }

Replies are listed 'Best First'.
Re^3: Trash in my prints
by Anonymous Monk on Aug 18, 2011 at 22:33 UTC

    That did the trick.

    The code where I found this problem spits a file as an attachment to the browser, kinda looks like this:

    sub render_file { my ( $x, %p ) = @_; my $content = read_file( $p{name}, binmode => ':raw' ); print $content; return Apache2::Const::OK; }
    nothing really complex. I didn't know $\ would affect the output of print, or rather, didn't know mod_perl would set it like blindluke says.

    What really strikes me as odd now is the fact that the code hasn't changed in ages and no one had noticed it was broken...

    You learn something new everyday. Thanks everyone!

      nothing really complex. I didn't know $\ would affect the output of print, or rather, didn't know mod_perl would set it like blindluke says.

      mod_perl does not set it, it even warns you about these ($\) special global variables