Rene Schickbauer

NAME

Maplat::Helpers::FileSlurp - read in whole files from filename

SYNOPSIS

  use Maplat::Helpers::FileSlurp qw(slurpTextFile slurpBinFile);
  
  my @lines = slurpTextFile('HelloWorld.txt');
  my $bindata = slurpBinFile('camel.jpeg');

DESCRIPTION

This Module provides convinience functions to slurp in files. On text files, it also tries *very* hard to fix line endings, split the file correctly into lines and return an array of already chomp()'ed lines.

slurpTextFile

Takes one argument, the filename. It reads in the file in binary mode, fixes the line endings, breaks up the file into individual lines and returns an array of already chomp'ed lines. There might be some special cases where this doesn't work (most likely in files where multiple empty lines have mixed file endings), but so far it worked for me.

slurpBinFile

Takes one argument, the filename. It reads in the file in binary mode and returns its contents as a single scalar. This function also tries very hard to work on all operating systems (especially on Windows where there are multiple, differently broken versions of perl.exe available).

AUTHOR

Rene Schickbauer, <rene.schickbauer@gmail.com>

COPYRIGHT AND LICENSE

Copyright (C) 2008-2011 by Rene Schickbauer

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.10.0 or, at your option, any later version of Perl 5 you may have available.