Harry Putnam wrote:
>
> "John W. Krahn" <[EMAIL PROTECTED]> writes:
>
> > Harry Putnam wrote:
> >>
> >> @sorted = sort @unsorted;
> >
> > You probably should use the keys of %name which are unique.
>
> How cool, I hadn't realized this expression:
> if ($name{$File::Find::name}++ == 0){
> Actually put a value in that slot of %name.
Yes it has to or the expression $name{$File::Find::name}++ would always
be zero. Lookup the word autovivification in the docs.
> But it doesn't really give the results I was after either. I wanted
> the sort on short *.pod name. Other wise I have things like:
> /usr/lib/perl5/5.6.1/Win32.pod
> coming first.
>
> So my formulation may be better in that regard.
Populate the hash like this:
$name{ $File::Find::name } = $_;
And then get the sorted list like this:
@sorted = sort { $name{ $a } cmp $name{ $b } } keys %name;
John
--
use Perl;
program
fulfillment
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]