File-Slurp reviews

cpanratings
 

RSS | Module Info | Add a review of File-Slurp

File-Slurp (9999.19) *****

If you want to read the entire contents of a file into a string, this is the module for you! I use it all the time. The alternative for only the "read_file" or "slurp" function it provides is the following:

# Read entire file into one string
sub read_file {

my $filename = shift;

my $text = do { local( @ARGV, $/ ) = $filename ; <> } ;

return $text;
}

Do you really want this function copied and pasted throughout your code base? Just Don't repeat yourself (DRY) and

use File::Slurp qw(read_file)

!

File-Slurp (9999.19)

uri here. glad to see some nice reviews. check out the .19 version which has edit_file and edit_file_lines. these are similar to the -p/-i options on the command line. you can edit a file in-place (whole file or line by line).

if your review complained about the lack of utf8 support, that was fixed too so please update your comments.

thanx,

uri

File-Slurp (9999.14) *****

The newly-released version has fixes for the huge bug mentioned above: it works with :encoding by passing it off to binmode. Huzzah, File::Slurp is finally worth using! Many thanks to the new maintainer Uri Guttman for picking through the patches on RT and rolling them into the latest release. I hear good things for the future too!

File-Slurp (9999.13) ***

I've been using File::Slurp for years and is generally satisfied with it. However reading the negative reviews today and looking at its RT queue, I realize that this module is broken for many and is effectively abandoned by the maintainer (no new releases for almost 3 years now despite several RT items labeled as critical). So I suggest others checking out the alternatives.

My wishlist for File::Slurp is: a reading mode to automatically chomp newline (very useful for reading simple one-line files).

UPDATE: The maintainer said that a new release is being prepared, along with my new wishlist. Yay!

File-Slurp (9999.13) *

Simply unacceptable that this module does not work properly in utf-8 environments, failing to pick up on PERL_UNICODE=SAD or handle :raw properly.

See rt.cpan.org/Public/Bug/Display.html?i...

Ironically the documented { atomic => 1, binmode => ':raw' } will give "wide character" error in syswrite(). The undocumented { atomic => 1, binmode => ':utf8' } may actually work.

File-Slurp (9999.13) **

The module does _not_ operate properly with :encoding. After two years bug rt.cpan.org/Ticket/Display.html?id=34444 is still there patiently waiting to be fixed.

It is too much frustration for a simple localized $/

Perl6-Slurp is much cooler and powerful (eg: regex input record separator) although it lacks 'write_file'.

search.cpan.org/~dconway/Perl6-Slurp-...

If you need raw access File-Map is another contender

search.cpan.org/dist/File-Map/lib/Fil...

File-Slurp (9999.13) *****

This module is making perl programming SO MUCH easier...

maybe I cannot finely tune the file reading, but most of the time I just need to read the damn file - and it's exactly what this does.

File-Slurp (9999.13) *****

A lovely package that makes simple but tedious tasks easier. Well documented and very useful.

File-Slurp (9999.12) **

I really liked this module until the first time I got bitten by its failure to interoperate properly with :encoding on filehandles. I've decided it's almost always easier to just localize $/ briefly and read that way. It's a little uglier and more piggish, but it's more likely to work in odd conditions.

File-Slurp (9999.09) *****

Overall, I like this module a lot and use it constantly. I have one huge complaint though. There is a critical dataloss bug in the current version that has been unaddressed by the author for the last two weeks.

This command will truncate the file "foo" to zero bytes regardless of what's in the file.

perl -MFile::Slurp -e'append_file("foo", "")'

This could be fixed by a simple workaround: in the append_file function:

return if (-e $file && $content eq "");

UPDATE: The above bug is fixed and I love this module again! Thanks, Uri.

File-Slurp (9999.09) *

It just doesn't work all of the time. I can slurp one file, but then the second file it claims doesn't exist or it is unable to read anything from it.

I don't have the time to diagnose why it doesn't work. It was faster to write my own few lines which were adequate for what I needed.

File-Slurp (9999.01) **

I used to list File::Slurp as a dependency for my module, but 9999.01 didn't pass tests. It's also by a different author to the version previously rated as 5*, and has an entirely new codebase.

I replaced it with three lines of code, and for once don't regret the loss of modularity at all.

File-Slurp (2004.0904) *****

A few convenient functions that help uncluttering your code when you need to read (or write) an entire file into (or from) a scalar or an array.

Of course you could write them yourself, but why? They are in File::Slurp, use them.

The version number is quite surprising: I had never seen a module with a date as the version number, much less a date in the future.

Note that an other module, Slurp, which I have never used, seems to do quite the same thing, in a slightly different way: it lets you slurp several files in a single scalar, array or array_ref, but doesn't have functions to write to a file.