in reply to Re: Re: Re: Producing 2 lists from a grep call
in thread Producing 2 lists from a grep call

However (you knew that was coming right?), as I can do:
my (@a1,@a2) = ([1,2,3],[3,2,1]);

This doesn't work, sorry. You get @a1 with two array references and @a2 undefined.

tstock

Update : This is your one liner: (someone please -- me down for posting this)
map { ($_ ne '.') && ($_ ne '..') && push @{ -d "$base/$_" ? \@dirs : \@files }, $_ } (readdir DIR);
I think we can agree that the FOR LOOP/IF STATEMENT is probably a nicer solution ? :)

Replies are listed 'Best First'.
Re^5: Producing 2 lists from a grep call
by Aristotle (Chancellor) on Jun 17, 2002 at 12:28 UTC
    I think we can agree that the FOR LOOP/IF STATEMENT is probably a nicer solution ? :)
    Especially since it's almost the for loop I posted - just s/map/for/, pull the (readdir DIR) up top, slip a next into the loop, and there you have it.

    If you actually want something that's not a for loop in disguise, you could pull a really horrible trick like
    my @dir; my @files = map { ($_ ne '.') && ($_ ne '..') && -d "$base/$_" ? do { push @dir, $_; () } : -f "$base/$_" && $_ } readdir DIR;
    But if the Communications Decency Act had gone through I wouldn't have been able to even post this.

    Makeshifts last the longest.