in reply to Re^2: use of diamond operator for multiple files
in thread use of diamond operator for multiple files
This isn't what I would consider a golfy solution, but it is more brief:
my @data; for my $file (qw(this.txt that.txt)) { open my $fh, '<', $file or die $!; push @data, []; while( <$fh> ) { push @{$data[-1]}, $_ if /\n\z/ && ! /^>/; } }
If you want that in the form of a subroutine:
@data = read_files( qw(this.txt that.txt) ); sub read_files { my @data; for my $file ( @_ ) { open my $fh, '<', $file or die $!; push @data, []; while( <$fh> ) { push @{$data[-1]}, $_ if /\n\z/ && ! /^>/; } return @data; }
(Untested)
Dave
|
|---|