[Boston.pm] splitting on new lines is losing some lines?

"Greg London" <email-2Ro/Dj86MvDSUeElwK9/[email protected]> Fri, 29 May 2020 12:51:16 -0500
Newsgroups gmane.comp.lang.perl.perl-mongers.boston
Message-ID <[email protected]>
I feel like I'm losing my mind on this.
Why would perl do this?


This script:


#!/bin/env perl

use warnings;
use strict;
use Data::Dumper;


my $block=<<'BLOCK';

alpha
bravo


charlie
delta



BLOCK
;

print "block is:vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv\n";
print $block;
print "^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n";

my @lines = split(/\n/, $block);

print "when I split on \\n, I get this:\n";
print Dumper \@lines;





OUTPUT OF SCRIPT IS:

block is:vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv

alpha
bravo


charlie
delta



^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
when I split on \n, I get this:
$VAR1 = [
          '',
          'alpha',
          'bravo',
          '',
          '',
          'charlie',
          'delta'      <======== SHOULD BE SOME BLANK ENTRIES AFTER DELTA
        ];