in reply to Re: Works locally but not on Info Server
in thread Works locally but not on Info Server

Thank you that worked but not understanding how you got it to work? Is the map function what made the difference? I looked it up and it stores output info in an anonymous arrays? Can someone please explain in more simpler language what the map function did in this script???
  • Comment on Re: Re: Works locally but not on Info Server

Replies are listed 'Best First'.
Re: Re: Re: Works locally but not on Info Server
by Mr. Muskrat (Canon) on Jan 17, 2003 at 14:01 UTC

    I'll explain the map section for you.

    my @files = grep { !/.+$/ && -M $_ > 1; } map { $mydir."/".$_; } readdir(DIR);

    is basicly the same as

    # get the base file names my @files = readdir(DIR); # for each $file in @files, append the path to the front @files = map { $mydir."/".$_; } @files; # for each $file in @files, if it doesn't match the criteria then remo +ve it from @files @files = grep { !/.+$/ && -M $_ > 1; } @files;

    I hope that I didn't confuse you even more (:

      my @files = grep { !/^\.+$/ && -M $_ > 1; } map { $mydir."/".$_; } readdir(DIR);

      There is no point in doing that regex (corrected to your version above) after map, it will always fail. Also, you may want to skip all dot-files, since they are supposed to be hidden.

      my @files = grep { not /^\./ and -M "$mydir/$_" > 1 } readdir(DIR);

      — Arien