zjunior has asked for the wisdom of the Perl Monks concerning the following question:
Hi Monks. Consider this slice of code:
# (...) sub indexfiles { my $cod = $_[0] || die $!; my $root = $_[1] || '.'; # XXX how to correct this? our @files; find(\&wanted, $root); sub wanted { push(@files, $_) if /\.mp3$/; } open(DB, "> $dbpath/$cod.txt") || die $!; foreach(sort @files) { s/\.mp3$//; print DB $_, "\n"; } close(DB); } # (...)
In my habitual novice ignorance I tried to change the code a few times to look mode elegant. I don't like a sub inside another sub. And declaring a variable like that with our scares me, and possibly all you. :)
How to handle that with correctness, without mess the code and handle properly the @files array context?
Hoping that it wouldn't be too stupid... -- zjunior
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Using File::Find with a bit of elegance
by Kanji (Parson) on Mar 31, 2002 at 01:25 UTC | |
|
(jeffa) Re: Using File::Find with a bit of elegance
by jeffa (Bishop) on Mar 31, 2002 at 01:30 UTC | |
by jeffa (Bishop) on Mar 31, 2002 at 22:57 UTC | |
|
Re: Using File::Find with a bit of elegance
by runrig (Abbot) on Mar 31, 2002 at 04:44 UTC | |
|
Re: Using File::Find with a bit of elegance
by jepri (Parson) on Mar 31, 2002 at 01:42 UTC |