in reply to breaking up a file by delimiter

This gives the following correct output:

$VAR1 = ['This is a test.','This is a multiline test.']

Not on my perl. Here it gives:

$VAR1 = ['This is a test. ',' This is a multiline test. '];

As it's hard to know from that what you actually want, here's an SSCCE which preserves the multi-line nature of the second string but removes the trailling newlines. You can amend it to suit your actual requirements.

use strict; use warnings; use Test::More tests => 1; my @data; my @want = ('This is a test.', "This is a multiline\ntest."); { local $/ = "\nXXX\n"; chomp (@data = <DATA>); } is_deeply (\@data, \@want); __DATA__ This is a test. XXX This is a multiline test. XXX

Replies are listed 'Best First'.
Re^2: breaking up a file by delimiter
by Anonymous Monk on Oct 07, 2018 at 10:35 UTC