Hi jeff,

When I come to this site with some spare time, I try to work through some script that stretches my game a little bit. I had to add print statements to figure out your syntax but wanted to ask for clarification.

$ perl stat1.pl files are ./causes2.txt ./fears1.pl ./fears1.pl~ ./fears2.txt ./stat1. +pl ./stat1.pl~ ./template_stuff 240 282 242 63 396 362 4096 subroutine says this is your hash: key: ./stat1.pl, value: HASH(0xa1519ac) key: ./causes2.txt, value: HASH(0xa0fe7ec) key: ./fears1.pl, value: HASH(0xa118598) key: ./fears1.pl~, value: HASH(0xa117ddc) key: ./fears2.txt, value: HASH(0xa12c59c) key: ./stat1.pl~, value: HASH(0xa17581c) key: ./template_stuff, value: HASH(0xa22a8d4) $

Q1) Why are directories always 4096 on my linux machine, regardless of whatever is in it?

I really couldn't understand the map and resulting hash until I saw that the values were themselves hash references. I'm not suggesting that I added to your script in any way to improve it; rather it is simply more verbose:

$ cat stat1.pl use strict; use warnings; use 5.010; use lib "template_stuff"; use utils1 qw(print_hash); my @files = glob('./*'); my %stat = map { $_ => { r => (-r $_), w => (-w $_), x => (-x $_), s => (-s $_), } } @files; say "files are @files"; # print out all sizes, as an example print $stat{$_}{s}, $/ for @files; my $hashref = \%stat; print_hash ( $hashref ); $

Q2) Do I have it correct that the stat hash has an array reference as its value, where it references a hash with the letters for filetests as keys and their stat'ed values for any given file as values?

Q3) How would I enumerate them, that is, display all their values for a directory?

Thanks for your interesting post and comment,


In reply to Re^2: Is it possible to localize the stat/lstat cache? by Aldebaran
in thread Is it possible to localize the stat/lstat cache? by bounsy

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.