my @foo; { local $/ = 'certain string'; open my $file, '<', '/path/to/afile' or die $!; @foo = (<$file>)[0..2]; }