Algorithm-Diff-HTMLTable
view release on metacpan or search on metacpan
lib/Algorithm/Diff/HTMLTable.pm view on Meta::CPAN
if ( ref $file && ref $file eq 'ARRAY' ) {
return @{ $file };
}
return if !-r $file;
my @lines;
open my $fh, '<', $file;
if ( $self->{encoding} ) {
binmode $fh, ':encoding(' . $self->{encoding} . ')';
}
local $/ = $self->{eol} // "\n";
@lines = <$fh>;
close $fh;
return @lines;
}
t/09_read_file.t view on Meta::CPAN
{
is $table->_read_file, undef, 'No file at all';
is $table->_read_file({}), undef, 'Hashref is not accepted';
is_deeply [$table->_read_file(['Test']) ], ['Test'], 'Arrayref - handled as lines';
is_deeply [$table->_read_file([]) ], [], 'Arrayref - handled as lines';
is $table->_read_file( '/does/not/exist/algorithm_diff_htmltable.t' ), undef;
}
{
my $fh = File::Temp->new;
binmode $fh, ':encoding(utf-8)';
print $fh "Hallo\nTest";
my $name = $fh->filename;
close $fh;
is_deeply [ $table->_read_file( $name ) ], ["Hallo\n", "Test"];
}
done_testing();
( run in 0.237 second using v1.01-cache-2.11-cpan-3cd7ad12f66 )