... I'm still not completely clear what local $/ = ''; does ... perlvar does not discuss what it means to set it like this ...
Quoth perlvar:
IO::Handle->input_record_separator(EXPR)So yes, local $/ = ''; sets what you might call "indulgent" (update: or maybe "greedy"?) paragraph mode.
$INPUT_RECORD_SEPARATOR
$RS
$/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. ...
Try assigning "\n\n" to $/ as an experiment; how many blocks get printed out then?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 >>
Give a man a fish: <%-{-{-{-<
In reply to Re^5: using Path::Tiny and reformating result
by AnomalousMonk
in thread using Path::Tiny and reformating result
by Aldebaran
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |