in reply to Re: slurping into scalars
in thread slurping into scalars

Is it possible to alter this so every new-line is printed to a new-line?? for some reason this merges all lines together. ;-)

Replies are listed 'Best First'.
Re: Re: Re: slurping into scalars
by rob_au (Abbot) on Dec 16, 2002 at 10:22 UTC
    This is not normal behaviour and where we will need to see some code to understand what is happening. Altering the value of the input record separator, $/, in the manner described has no effect on the substance of the data read into the scalar variable.

     

    perl -le 'print+unpack("N",pack("B32","00000000000000000000000111111000"))'

Re: Re: Re: slurping into scalars
by dingus (Friar) on Dec 16, 2002 at 11:11 UTC
    Is it possible to alter this so every new-line is printed to a new-line?? for some reason this merges all lines together.
    $_ = join("\n", <FILE>);
    Adds a second \n to every line. This may be what you are looking for. Seems a bit odd though.

    I have done this kind of thing (with some differences) when doing quick and dirty text->html output. Say you want to put <p> tags when you have blank lines but otherwise leave the text untouched then the folowing code works:

    do {local $/ = $/.$/;print join('<p>', <FILE>);};

    Dingus


    Enter any 47-digit prime number to continue.