in reply to Re^4: using Path::Tiny and reformating result
in thread using Path::Tiny and reformating result

... I'm still not completely clear what local $/ = ''; does ... perlvar does not discuss what it means to set it like this ...

Quoth perlvar:

The input record separator, newline by default. This influences Perl's idea of what a "line" is. ... [Treats] empty lines as a terminator if set to the null string. ... 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. ...
So yes,  local $/ = ''; sets what you might call "indulgent" (update: or maybe "greedy"?) paragraph mode.
c:\@Work\Perl\monks\Magnolia25>perl -wMstrict -le "my $data = qq{line 1 \n} . qq{line 2 \n} . qq{\n} . qq{\n} . qq{\n} . qq{\n} . qq{\n} . qq{line 8 \n} . qq{line 9 \n} . qq{\n} . qq{\n} . qq{\n} . qq{\n} . qq{line 14 \n} . qq{\n} . qq{\n} . qq{\n} ; print qq{[[$data]] \n}; ;; open my $dfh, '<', \$data or die $!; ;; local $/ = ''; while (<$dfh>) { print qq{block <<$_>>}; } " [[line 1 line 2 line 8 line 9 line 14 ]] block <<line 1 line 2 >> block <<line 8 line 9 >> block <<line 14 >>
Try assigning  "\n\n" to  $/ as an experiment; how many blocks get printed out then?

Give a man a fish:  <%-{-{-{-<

Replies are listed 'Best First'.
Re^6: using Path::Tiny and reformating result
by Aldebaran (Chaplain) on Jul 04, 2018 at 20:59 UTC

    Thank you, AM.anomylous. All the words were there in perlvar, but I couldn't put it together without your well-contrived example. It was certainly a teachable moment for me, and I'd like to be able to show it precisely, so I worked up a bash script for the output and layout with monastery-conforming tags. The first script is and sets the irs (not the taxers) to the null string. Output, then source listing: sets the irs to /n/n. Output, then source:

    I agree, local $/ = ''; sets what you might call "indulgent" or "greedy" paragraph mode.