in reply to How to push and print at the same time?
open(my $FOLDERS, '+>', "dirs.log") or die $!; find( sub { if (-d $File::Find::name && !$seen{$_}++) { push @folders, "$_"; print $FOLDERS "$_\n"; }, $cwd );
Alternatively, since your push will always return true (a positive integer), you can create a compound statement with and, though that's getting a little cute I think.
open(my $FOLDERS, '+>', "dirs.log") or die $!; find(sub { push @folders, "$_" and print $FOLDERS "$_\n" if -d $File:: +Find::name && !$seen{$_}++;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: How to push and print at the same time?
by ikegami (Patriarch) on Mar 22, 2011 at 16:02 UTC |