in reply to Re: Retrieve only what I need from split without using temp array
in thread Retrieve only what I need from split without using temp array

um - why dont you use File::Stat's OO interface - surely it is also clearer to others what you are doing
use File::Stat; print File::Stat->new($file)->size(), "\n";
granted, this is a module that isn't standard in Perl, as opposed to stat(), so you need to do the MakeMaker waltz, but I think it is worth going the extra mile for the much clearer code.
Is there a reason why you prefer stat() ?
  • Comment on Re: Re: Retrieve only what I need from split without using temp array
  • Download Code

Replies are listed 'Best First'.
Re: Re: Re: Retrieve only what I need from split without using temp array
by RMGir (Prior) on Aug 06, 2003 at 11:55 UTC
    granted, this is a module that isn't standard in Perl, as opposed to stat(), so you need to do the MakeMaker waltz, but I think it is worth going the extra mile for the much clearer code.

    In many cases, scripts have to run on multiple platforms, with different versions of perl/mod_perl. In those situations, it's painful to have to build File::Stat just so someone doesn't have to see my $size=(stat $file)[7], which is pretty clear anyhow if you assign it to an appropriately named variable.

    If you KNOW all the platforms have 5.8.0 or better available, you could use File::stat, but I'm not sure that's that big a win either over just plain stat. I guess I just prefer the builtin in this case.
    --
    Mike

Re3: (File's size) Retrieve only what I need from split without using temp array
by bbfu (Curate) on Aug 06, 2003 at 19:09 UTC

    Or even just: my $size = -s $file;

    bbfu
    Black flowers blossom
    Fearless on my breath