in reply to Re^2: perl challenge 3
in thread Reaped: perl challenge 3

#!/usr/bin/perl use File::Find::Rule; use warnings; my $filelist; sub buildFile { open ($filelist, ">", "filelist.txt") || die $!; # File find rule and # Provide specific list of directories to scan my $SubDirs= File::Find::Rule->directory->in('etc', 'dev', 'bin'); + # interpret Size Method and stored the list on @files my @files = File::Find::Rule->size('500')->in($SubDirs); print $filelist map { "$_\n" } @files; return \$filelist; }

this is what i had can someone correct me

Replies are listed 'Best First'.
Re^4: perl challenge 3
by FreeBeerReekingMonk (Deacon) on Dec 16, 2015 at 01:14 UTC

    Query Method in( @directories )
    so ->in($SubDirs); has to be an array, and not a scalar string.

    Hint: qw(/etc /dev /bin) creates a nice array with those directories.

    Please notice the slash at the beginning. A directory always has that...



    perl -MFile::Find::Rule -e 'print join("\n", File::Find::Rule->directory->in(qw(/etc /dev /bin)));'

      do i need to replace my line with your line or just add the slashes

        you need to replace
         my $SubDirs= File::Find::Rule->directory->in('etc', 'dev', 'bin');
        with

        my @startDirs = qw(/etc /dev /bin); my @SubDirs= File::Find::Rule->directory->in( @startDirs );

        and then use @SubDirs in the next statement... this might work (untested) it could also ve @startDirs

Re^4: perl challenge 3
by Anonymous Monk on Dec 16, 2015 at 01:15 UTC

    this is what i had can someone correct me

    Does it need correcting?

      i get no output and no errors as well does that mean there is no file larger than 500kbyte

        i get no output and no errors

        as well does that mean there is no file larger than 500kbyte

        Good question, you have taken step one in Basic debugging checklist , now just keep going , simplify the question, the code, repeat

        Write a program to find out, are there any files at all?

        could be... but I think you still have bugs in your program. See my other comment on how to fix those.