in reply to [untitled node, ID 150556]

Hi Samn.

It took me a few seconds to realize what was going on here, but you need to use <code> tags when you post. Otherwise, any HTML entities don't get encoded properly and so you get results like line 2 of your program, which looks like "@log = ;".

Anyway, the reason for the spaces is that you have put double quotes around your @log array. When an array is interpolated into a string, perl automagically does a join with the default record separator, which also happens to default to a space.

Just do print FILE @log; and you should be fine.

Update ++jeffa for correcting my hasty from-memory-explanation :)

..Guv

Replies are listed 'Best First'.
(jeffa) 2Re: \n and \r
by jeffa (Bishop) on Mar 09, 2002 at 18:29 UTC
    "When an array is interpolated into a string, perl automagically does a join with the default record separator, which also happens to default to a space."

    Close.

    The 'default record separator' (i think you mean the input record separator, $/, which defaults to a new line) is not used here, instead the list separator ($", which defaults to a space) is used. See perlvar for more. Also, page 13 of Network Programming w/ Perl lays out the scoop on end-of-line characters. If you don't have a copy (which you should), you can read a watered-down version of that discussion here: A Little History on 0D0A.

    jeffa

    L-LL-L--L-LL-L--L-LL-L--
    -R--R-RR-R--R-RR-R--R-RR
    B--B--B--B--B--B--B--B--
    H---H---H---H---H---H---
    (the triplet paradiddle with high-hat)