Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re^2: HOP Iterator Ex4.3-- Illegal declaration

by ady (Deacon)
on Mar 03, 2006 at 15:46 UTC ( [id://534256]=note: print w/replies, xml ) Need Help??


in reply to Re: HOP Iterator Ex4.3-- Illegal declaration
in thread HOP Iterator Ex4.3-- Illegal declaration

ooOOOOOPPPss, Yes of course -- some months since i've been in Perl land...
sorry- but Thanks!
Allan
  • Comment on Re^2: HOP Iterator Ex4.3-- Illegal declaration

Replies are listed 'Best First'.
Re^3: HOP Iterator Ex4.3-- Illegal declaration
by ady (Deacon) on Mar 03, 2006 at 15:53 UTC
    Ok, up n' running :
    use strict; use warnings; ### -------------------------- Util ----------------------- sub Iterator (&) { return $_[0] } sub NEXTVAL { $_[0]->() } ### -------------------------- Iterator ------------------- sub interesting_files { my $is_interesting = shift; my @queue = @_; return Iterator { while (@queue) { my $file = shift @queue; if (-d $file) { opendir my $dh, $file or next; my @newfiles = grep {$_ ne "." && $_ ne ".."} readdir + $dh; push @queue, map "$file/$_", @newfiles; } return $file if $is_interesting->($file); } return; }; } ### -------------------------- FileMask ------------------- sub is_WrappedXml { my $file = shift; return 1 if $file =~ /WrappedXml.{0,5}\.xml/i; return; } ### -------------------------- MAIN ----------------------- my $WrappedXml_file = interesting_files(\&is_WrappedXml, '.'); while (defined(my $file = NEXTVAL($WrappedXml_file))) { print "$file\n"; }

    Best regards, Allan Dystrup

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://534256]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (1)
As of 2024-04-25 03:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found