Skip Menu |

This queue is for tickets about the File-Slurper CPAN distribution.

Report information
The Basics
Id: 114341
Status: open
Priority: 0/
Queue: File-Slurper

People
Owner: Nobody in particular
Requestors: abe [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: Please document return values of write_* functions
Date: Thu, 12 May 2016 02:57:39 +0200
To: bug-File-Slurper [...] rt.cpan.org
From: Axel Beckert <abe [...] cpan.org>
Hi, The POD does not mention the return values of the write_* functions. As it seems they _always_ return false (undef or empty array). Even if that's on purpose or by design, it should be mentioned in the POD. Nevertheless, I think File::Slurper should adopt the return values used by File::Slurp: By default "write_file" returns 1 upon successfully writing the file or undef if it encountered an error. Example: I have tons of Test::More tests which look like this: ok(write_file($file, $string), "$file successfully written"); With File::Slurper, they look much uglier: write_file($file, $string); ok(-f $file, "$file successfully written"); (Sometimes I use -f, sometimes -s. But I consider both to be more fragile than File::Slurp::write_file's return value for this purpose.) Kind regards, Axel -- /~\ Plain Text Ribbon Campaign | Axel Beckert \ / Say No to HTML in E-Mail and News | abe@deuxchevaux.org (Mail) X See http://www.nonhtmlmail.org/campaign.html | abe@noone.org (Mail+Jabber) / \ I love long mails: http://email.is-not-s.ms/ | http://abe.noone.org/ (Web)
On 2016-05-11 20:57:55, abe@cpan.org wrote: Show quoted text
> Hi, > > The POD does not mention the return values of the write_* functions. > > As it seems they _always_ return false (undef or empty array). Even if > that's on purpose or by design, it should be mentioned in the POD. > > Nevertheless, I think File::Slurper should adopt the return values > used by File::Slurp: > > By default "write_file" returns 1 upon successfully writing the file > or undef if it encountered an error. > > Example: I have tons of Test::More tests which look like this: > > ok(write_file($file, $string), "$file successfully written"); > > With File::Slurper, they look much uglier: > > write_file($file, $string); > ok(-f $file, "$file successfully written"); > > (Sometimes I use -f, sometimes -s. But I consider both to be more > fragile than File::Slurp::write_file's return value for this purpose.) >
Reading the source it seems that File::Slurper is using exceptions. So you have to write: ok eval { write_text($file, $string); 1 }, "$file successfully written"; Of course, the fact that exceptions are used should be documented...
Subject: Re: [rt.cpan.org #114341] Please document return values of write_* functions
Date: Mon, 16 May 2016 00:29:08 +0200
To: bug-File-Slurper [...] rt.cpan.org
From: Leon Timmermans <leont [...] cpan.org>
On Sun, May 15, 2016 at 9:53 PM, Slaven_Rezic via RT < bug-File-Slurper@rt.cpan.org> wrote: Show quoted text
> Reading the source it seems that File::Slurper is using exceptions. So you > have to write: > > ok eval { write_text($file, $string); 1 }, "$file successfully > written"; > > Of course, the fact that exceptions are used should be documented... >
Agreed. Leon