I've just started trying to pick up a little perl.
I'm breezing through "Learning Perl" and reading the perl docs.

Here is some syntax I found a little funny, and I was hoping somebody
could explain this too me:

opendir(DIR, $some_dir) || die "can't opendir $some_dir: $!";
@dots = grep { /^\./ && -f "$some_dir/$_" } readdir(DIR);
closedir DIR;

The first and 3rd lines I have no problem with.

Its that line with the grep in it.
grep is obviously a built-in perl function.

This is something I've seen before ...
the output of the function readdir is "trickling down" to become the
input of the function grep ?

In C or Java you would write
grep(readdir(DIR)) most likely ?

If that is so, what is all that business with the curly braces ?
I thought curly braces are supposed to denote code sections ?

So, it's like the output of readdir is "trickling" through the curly
braces and then the output after this is "trickling" through grep ?

If so, what is the "input" to the code section in the curly braces ?

Anyhow, all this is a bit weird to me, so I was hoping someone could
shed some light on it.

thanks and cheers,
e

p.s. It seems some of my confusion comes from the fact that I am used to
putting () around funtion calls. That still doesn't help with the curly
braces though ... %^)

-- 
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