-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Dr.Ruud wrote:
> Mathew Snyder schreef:
>
>> foreach my $file (sort(readdir DH)){
>> next if ($file =~ /^.%|^..$/);
>> my $mod_time = (stat($file))[9];
>> $filenames{$file} = $mod_time;
>> }
>
> No need to sort before you put things in a hash: hashes don't keep
> order.
>
>
> Try this:
>
> my %file_modtime = map { m~([^/]*)$~ => (stat)[9] } grep -f,
> </usr/bin/*>
>
>
> The capturing regex
>
> m~([^/]*)$~
>
> isolates the filename, you can also use
>
> (split '/')[-1]
>
> or a basename-function from some module.
>
I had given up on the hash because that was confusing me as well. I
stuck with an array.
Couple of corrections: I removed the right ']' that I left in the match
expression and removed the initialization to 0 for 'my $file_count'
since it doesn't need to be set to an initial value anyway.
- --
Mathew
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQFFE6wLr7cEqtYW7kARAhZ0AJwP6WqQtE+PQHlHnp59C3zuiTQYUwCfToqk
DbMRMB+3lta0HeycnwJLP9o=
=sqmc
-----END PGP SIGNATURE-----
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>