Footprintless
view release on metacpan - search on metacpan
view release on metacpan or search on metacpan
lib/Footprintless/Util.pm view on Meta::CPAN
}
return $rebased;
}
sub slurp {
my ($file) = @_;
# http://www.perl.com/pub/2003/11/21/slurp.html
return $file
? do { local ( @ARGV, $/ ) = $file; <> }
: do { local $/; <STDIN> };
}
sub spurt {
my ( $content, $file, %options ) = @_;
my $write_mode = $options{append} ? '>>' : '>';
open( my $handle, $write_mode, $file )
|| croak("unable to open [$file]: $!");
print( $handle $content );
close($handle);
t/Footprintless_Util.t view on Meta::CPAN
};
my $logger = Log::Any->get_logger();
my $temp_dir = File::Temp->newdir();
$logger->trace( 'temp_dir [%s]', $temp_dir );
my $spurt_file = File::Spec->catfile( $temp_dir, 'spurt' );
$logger->trace( 'writing to [%s]', $spurt_file );
Footprintless::Util::spurt( 'foo', $spurt_file );
is( do { local ( @ARGV, $/ ) = $spurt_file; <> }, 'foo', 'spurt' );
my $slurp_file = File::Spec->catfile( $temp_dir, 'slurp' );
$logger->trace( 'writing to [%s]', $slurp_file );
open( my $handle, '>', $slurp_file ) || croak("cant open $slurp_file");
print( $handle 'bar' );
close($handle);
is( Footprintless::Util::slurp($slurp_file), 'bar', 'slurp' );
like( Footprintless::Util::dumper( { foo => 'bar' } ),
qr/^\s*\$VAR1\s+=\s+\{\s+'foo'\s+=>\s+'bar'\s+\};\s*$/s, 'dumper' );
view all matches for this distributionview release on metacpan - search on metacpan
( run in 0.477 second using v1.00-cache-2.02-grep-82fe00e-cpan-da92000dfeb )