in reply to foreach and opendir differences

It's not actually a foreach problem.

my @dirvar = </xxx/*> print join ':', @dirvar;
It's a glob problem. Which reminds me - I recommend avoiding the <...> operator for that. Not just because it's a pain to type and get to display properly here ;-), but because using "glob" is so much more obvious as to what you're doing. (<...> is implemented in terms of glob, so this doesn't change anything functionally)
my @dirvar = glob "/xxx/*";
Looking up glob in the perlfunc documentation (e.g., "perldoc -f glob"), you see it is implemented via File::Glob. Looking that up, you see it tries to implement C shell semantics. This sets off warning bells: on unix, files with a leading dot are considered "hidden" and should not be shown by default. So "*" does not match leading dots. Other dots, but not leading dots. Looking C shell up (I'm a Korn shell/Bourne-again shell type of guy m'self), I see that this should work:
my @dirvar = glob "/xxx/{.,}*";
The reason? Braces denote choices, all of which apply. The comma separates the choices. So this expands to both "/xxx/.*" and "/xxx/*" simultaneously, in a single call.

readdir, by the way, does not use shell semantics, and thus ignores "hidden" attributes, laying everything out for you.

HTH