#!/usr/bin/env perl use Modern::Perl; use autodie; use Data::Dump 'pp'; open my $file, "<", "input.txt"; { local $/ = "--\n"; say pp <$file>; } close $file;
And the conclusion:
( "--\n", "read50_1: read1391364_2,read3529226_1,\n--\n", "read46_2: read916_1,read178252_2,read1336397_1,read1824459_2,\nread916_1: read0_1\n--\n", "read34_1: read209771_2,\n--\n", "read32_2: read520377_2,\n", )
In other words, reading does not separate the input delimiter. You might want something like this:
open my $file, "<", "input.txt"; { local $/ = "--\n"; for (<$file>) { chomp; s/\n//g; say "<$_>"; } } close $file;
What gives:
<> <read50_1: read1391364_2,read3529226_1,> <read46_2: read916_1,read178252_2,read1336397_1,read1824459_2,read916_1: read0_1> <read34_1: read209771_2,> <read32_2: read520377_2,>
As an additional note, you should use tri-arg open , and you might be interested in autodie , so you don't have to write or die patterns.