[Melbourne-pm] I <3 map & grep

Toby Corkindale toby.corkindale at strategicdata.com.au
Wed Oct 26 22:34:37 PDT 2011


On 27/10/11 16:25, Myf White wrote:
> Have you thought about using File::Find::Rule?

Good point, that would probably look a bit more sane.
Although to achieve the same behaviour I think I'd need to add more 
parameters, like maxdepth and a regex.

I think I was going to use my regex to eliminate files such as 
.filename.swp and the like, but that's not what it's doing now.
I should fix it up.

Cheers,
Toby

> my %sites =
>      map { $_->{name} => Streuth::Site->new($_) }
>      map { { ParseConfig($_) }}
>      File::Find::Rule->file()->in( $self->sites_dir );
>
>
> Kind Regards,
> Myf White*
> Email:*myfwhite at gmail.com <mailto:myfwhite at gmail.com>
>
>
> On Thu, Oct 27, 2011 at 4:07 PM, Toby Corkindale
> <toby.corkindale at strategicdata.com.au
> <mailto:toby.corkindale at strategicdata.com.au>> wrote:
>
>     But perhaps, a little too much..
>     I just found myself this:
>
>
>         use Config::General qw(ParseConfig);
>         ...
>         opendir(my $dir, $self->sites_dir) or die..;
>
>         my %sites = map  { $_->{name} => Streuth::Site->new($_) }
>                     map  { { ParseConfig($_) } }
>                     grep { -f $_ }
>                     map  { File::Spec->catfile($self->__sites_dir, $_) }
>                     grep { /^[-_a-zA-Z\d\.]+$/ }
>                     readdir($dir);
>
>         closedir $dir;
>         return \%sites;
>
>     _________________________________________________
>     Melbourne-pm mailing list
>     Melbourne-pm at pm.org <mailto:Melbourne-pm at pm.org>
>     http://mail.pm.org/mailman/__listinfo/melbourne-pm
>     <http://mail.pm.org/mailman/listinfo/melbourne-pm>
>
>


-- 
.signature


More information about the Melbourne-pm mailing list