Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

problem with File::Util::readlimit

3 views
Skip to first unread message

Luca Ferrari

unread,
May 8, 2013, 12:49:48 PM5/8/13
to begi...@perl.org
Hello,
I'm encountering a problem with File::Util that I'm not able to see,
and I'm sure it's trivial:

my $handle_file = new File::Util;
my $files_for = {};
my $max_file_size = int( 1024 * 1024 * 1024 );
$handle_file->readlimit( $max_file_size );

that once run produces the following trace:

PROCESS TERMINATED DUE TO ERRORS

Bad call to File::Util::readlimit(). This method can only be called with
a numeric value (bytes). Non-integer numbers will be converted to integer
format if specified (numbers like 5.2), but don't do that, it's inefficient.

This operation aborted.

Origin: This is a human error.
Solution: A human must fix the programming flaw.

ARG _pak = File::Util
ARG bad = 1073741824

1. File::Util::_throw
-called at line (1518) of /usr/local/share/perl/5.14.2/File/Util.pm
-was called with args
-was not called to evaluate anything


2. File::Util::readlimit
-called at line (16) of test.pl
-was called with args
-was not called to evaluate anything



The documentation for File::Util::readlimit states that:

readlimit => positive integer
Optionally specify this option to the
File::Util::new method to instruct
the new object that it should never attempt to open
and read in a file
greater than the number of bytes you specify.
Obviously this argument can
only be a numeric integer value, otherwise it will
be silently ignored.
The default readlimit for File::Util objects is
52428800 bytes (50
megabytes).

Any idea about what I'm missing?

Thanks,
Luca

Peter Ezetta

unread,
May 8, 2013, 1:10:34 PM5/8/13
to Luca Ferrari, begi...@perl.org
Hi Luca,

I am hoping someone else can speak to this more than I can, but I messed around with your code and did a bit of reading on File::Util, and was able to get the code to execute properly as follows:

#!/usr/bin/env perl

use Modern::Perl 2011;
use autodie;
use File::Util;

my $max_file_size = int( 1024 * 1024 * 1024 );
my $handle_file = File::Util->new( readlimit => $max_file_size );
my $files_for = {};

say $handle_file->readlimit(); # Did it work?

__END__

You might try passing the readlimit to new instead of setting it after the fact, and see if that helps you out any.

Regards,

Peter
________________________________________
From: fluc...@gmail.com [fluc...@gmail.com] On Behalf Of Luca Ferrari [fluc...@infinito.it]
Sent: Wednesday, May 08, 2013 9:49 AM
To: begi...@perl.org
Subject: problem with File::Util::readlimit
--
To unsubscribe, e-mail: beginners-...@perl.org
For additional commands, e-mail: beginne...@perl.org
http://learn.perl.org/



Confidentiality Notice: This e-mail may contain proprietary information some of which may be legally privileged. It is for the intended recipient(s) only. If you believe that it has been sent to you in error, please notify the sender by reply e-mail and delete the message. Any disclosure, copying, distribution or use of this information by someone other than the intended recipient(s) is prohibited and may be unlawful.

Brandon McCaig

unread,
May 8, 2013, 2:24:59 PM5/8/13
to Luca Ferrari, begi...@perl.org
On Wed, May 08, 2013 at 06:49:48PM +0200, Luca Ferrari wrote:
> Hello,

Hello,

> I'm encountering a problem with File::Util that I'm not able to
> see, and I'm sure it's trivial:
>
> my $handle_file = new File::Util;
> my $files_for = {};
> my $max_file_size = int( 1024 * 1024 * 1024 );
> $handle_file->readlimit( $max_file_size );
>
> that once run produces the following trace:
>
> PROCESS TERMINATED DUE TO ERRORS
*snip*
> Any idea about what I'm missing?

Looks like a module bug to me.

A freshly installed File/Util.pm said:
> sub readlimit {
> my $arg = _myargs( @_ );
>
> if ( defined $arg ) {
>
> return File::Util->new()->_throw
> (
> 'bad readlimit' => { bad => $arg }
> ) if $arg !~ /\D/o;
>
> $READLIMIT = $arg;
> }
>
> return $READLIMIT;
> }

Looks like it raises an exception if the argument doesn't match a
NON-"digit" character. Which seems like the opposite of what is
wanted.

Regards,


--
Brandon McCaig <bamc...@gmail.com> <bamc...@castopulence.org>
Castopulence Software <https://www.castopulence.org/>
Blog <http://www.bamccaig.com/>
perl -E '$_=q{V zrna gur orfg jvgu jung V fnl. }.
q{Vg qbrfa'\''g nyjnlf fbhaq gung jnl.};
tr/A-Ma-mN-Zn-z/N-Zn-zA-Ma-m/;say'

signature.asc

Luca Ferrari

unread,
May 9, 2013, 2:51:23 AM5/9/13
to begi...@perl.org
On Wed, May 8, 2013 at 8:24 PM, Brandon McCaig <bamc...@gmail.com> wrote:
> Looks like it raises an exception if the argument doesn't match a
> NON-"digit" character. Which seems like the opposite of what is
> wanted.
>


In fact I was discovering it too reading the code, I've submitted a
bug report for this.

Thanks,
Luca

Brandon McCaig

unread,
May 9, 2013, 9:50:10 AM5/9/13
to Luca Ferrari, begi...@perl.org
On Thu, May 09, 2013 at 08:51:23AM +0200, Luca Ferrari wrote:
> In fact I was discovering it too reading the code, I've
> submitted a bug report for this.

I also submitted a bug report (so now I feel doubly bad for not
letting the list know so he didn't get duplicates; twice the
noise). I was informed that the latest code is already fixed. You
can apparently get it here:
<http://cpan.metacpan.org/authors/id/T/TO/TOMMY/File-Util-4.130610-TRIAL.tar.gz>.

The maintainer informs me that despite it being a "TRIAL" release
it has "months of stability" and he plans to release it soon as
"mature". So maybe keep an eye out for that too.
signature.asc
0 new messages