in reply to go through directories recursively

Use one of the File::Find-esque modules e.g
use File::Basename qw/ dirname basename /; use File::Find::Rule; my $rule = rule( file => start => '/data/input' ); while(my $path = $rule->match) { printf "%s,%s,%s\n", dirname($path), basename($path), -s $path; }
Update: or if you don't mind slurping the whole list
## do same 'use's as above printf "%s,%s,%s\n", dirname($_), basename($_), -s $_ for find( file => in => '/data/input' );
HTH

_________
broquaint

Replies are listed 'Best First'.
Re: Re: go through directories recursively
by danield (Novice) on Feb 03, 2004 at 18:21 UTC
    hello broquaint,

    Thank you for your suggestion, unfortunately I don't have package File::Find. When I run your script, it gives me this error:
    "go3.pl" [New file] 5 lines, 230 characters normal@firestarter:/data/input> perl go3.pl Can't locate File/Find/Rule.pm in @INC (@INC contains: /usr/perl5/5.00 +503/sun4-solaris /usr/perl5/5.00503 /usr/perl5/site_perl/5.005/sun4-s +olaris /usr/perl5/site_perl/5.005 .) at go3.pl line 2. BEGIN failed--compilation aborted at go3.pl line 2.
      Then you need to install the module, and fortunately I've covered this very subject before at Re: Re: Re: Find file name. One thing I forgot to mention there was that you'll also need to install Number::Compare and Text::Glob, if you haven't already, to fulfil FFR's dependencies.
      HTH

      _________
      broquaint

      danield, it's worth persevering with the File::Find::Rule install. So much easier than the opendir route. If you have root, it's no harder than:

      perl -MCPAN -e 'install File::Find::Rule';
      -- vek --