Harry wrote:
>> This new coding although easier to look at and probably more
>> efficient, isn't really any faster or at least not appreciably.  It
>> still goes to each and every numbered file.

John replied:
> In most file systems the file names are not stored in any particular
> order so in order to find every file of a certain type you have to
> look at every file in a directory to determine if it is the type you
> want.

So I guess there just isn't any tricky fast way to get just the
directory names then eh?  This is on ext3 fs but about the only real
change I could make there would be to reiserfs or something and I'll
assume that wouldn't really change the problem.

>> [...] snipped new code 

>> Also changing the file name regex from
>> /^\d+$/ to /^\d/ will cause problems in some directories where
>> there may be such things as 780~ or even 123.bak
>
> Your original example used /^\d+/ not /^\d+$/ and /^\d/ does the
> same thing as /^\d+/.

Oh .. now I see where you got it.  Because the actual program used
/^\d+$/ for the reasons I listed.  Must have been a foible or typo
during conversion to mail message.  I might not have cut and pasted
all of it or changed the program after posting... or something.

[...]

> sub something { ... }
> find( \&something, @directories );
>
> And
>
> find( sub { ... }, @directories );
>
> Do the same thing but the first uses a reference to a named
> subroutine and the second uses a reference to an anonymous
> subroutine.

OK, thanks for clearing that up...Is one better than the other in some
way?

> use File::Spec;
> use File::Find;

[...]

> my @top_dir = map File::Spec->rel2abs($_), splice @ARGV;
> my $file = './uniq_dir_under_news';

Is using File::Spec in this way, faster or more efficient than using
Cwd like in the original?  Or are you just showing another approach?

Thanks for that too, I hadn't run into File::Spec as yet and now have
a handy reference to its use when I need it.

Those perldoc pages are terrrible about showing enough examples.  But
mainly because I lack the expertise to understand the ones they do
give.

Well thanks for your usual patience and explanations...


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to