package Utl;
require 5.006_001;
use strict;
use warnings;
## a library of categorized utilities and functions
our $VERSION = 0.03;
our %slurp = (
## slurp a file to a scalar
## pass filename (as scalar)
## returns contents of file (scalar context)
to_scalar => sub{ local( *ARGV, $/ ); @ARGV = @_; <> },
## slurp one or more files to an array
## pass filename(s) (as scalar)
## returns contents of file(s) (list context)
## returns number of lines (scalar context)
to_array => sub{ local *ARGV; @ARGV = @_; <> },
);
### more utilities follow...
####
my $file = $Utl::slurp{to_scalar}->( $filename );
## or for an array...
my @file = $Utl::slurp{to_array}->( $filename );
####
.