Maplat::Helpers::FileSlurp - read in whole files from filename
use Maplat::Helpers::FileSlurp qw(slurpTextFile slurpBinFile); my @lines = slurpTextFile('HelloWorld.txt'); my $bindata = slurpBinFile('camel.jpeg');
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.
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.
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).
Rene Schickbauer, <firstname.lastname@example.org>
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.