File: demo_squeeze.pl

package info (click to toggle)
libperl6-slurp-perl 0.051000-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 144 kB
  • sloc: perl: 145; makefile: 2
file content (29 lines) | stat: -rw-r--r-- 348 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
use Perl6::Slurp;

sub squeeze {
    my ($removed) = @_;
    if ($removed =~ tr/\n/\n/ == 1) { return " " }
    else                            { return "\n\n"; }
}

print slurp(\*DATA, {irs=>qr/[ \t]*\n+/, chomp=>\&squeeze}), "\n";

__END__
This is the
first paragraph


This is the
second
paragraph

This, the
third




This one is
the
very
last