in reply to Re: Inserting values into an array
in thread Inserting values into an array

The OP is actually setting $/ correctly: $/="" reads paragraphs, as the post implies (s)he wants.

Replies are listed 'Best First'.
Re^3: Inserting values into an array
by tlm (Prior) on Jun 01, 2005 at 14:11 UTC

    Sorry, I did have difficulty parsing the OP, but for paragraphs I would think that setting $/="\n\n", or something like that, would be more appropriate, no?

    the lowliest monk

      tlm,
      Nope. Of course common sense would tell you that "" doesn't imply a paragraph, but reading perlvar it seems Perl made a special case to solve your paragraph slurping problems.

      Setting it to "\n\n" means something slightly different than setting to "" , if the file contains consecutive empty lines. Setting to "" will treat two or more consecutive empty lines as a single empty line. Setting to "\n\n" will blindly assume that the next input character belongs to the next paragraph, even if it's a newline. (Mnemonic: / delimits line boundaries when quoting poetry.)

      Cheers - L~R

      Added snippet from referenced doc
      I believe $/="" is special because it takes one or more blank lines as a record separator.

      Wierdly, the only documentation on this feature I can find quickly is in perlfaq6 - perlvar doesn't mention it at all.

      update: tested my assumption.

      Update2: Limbic~Region is right: it is mentioned in perlvar. For some reason I read past it.

      Update3: Also note that the description in perlvar is more accurate than mine, since it explains what happens with the "extra" blank lines (they're thrown away).

        Joost,
        perlvar doesn't mention it at all.

        Which version of perlvar are you reading? See my post for details.

        Cheers - L~R