perlquestion
kamal
I have just started to delve into Perl, and going through the following example:
<code>
#!/usr/bin/perl
use strict;
use warnings;
use Path::Class;
my $dir = dir('foo','bar'); # foo/bar
# Iterate over the content of foo/bar
while (my $file = $dir->next) {
# See if it is a directory and skip
next if $file->is_dir();
# Print out the file name and path
print $file->stringify . "\n";
}
</code>
Reading the code....
<code>
my $dir = dir ('test1');
</code>
<p>
# local scalar dir is assigned by dir ('test1')<br>
the dir on the RHS, being possibly from Path::Class (CPAN)<br>
while (This condition hold true)<br>
# Simple While<br>
</p>
<p>
my $file = $dir->next
$dir scalar de-references the function next ? HOW ?<br>
HOW do i guess that next would indeed be written as next and not next(), etc<br>
since there is NO reference/example for "next" in<br>
<a href="http://search.cpan.org/~kwilliams/Path-Class-0.26/lib/Path/Class.pm">Class.pm</a>
Same goes for stringify, or is_dir()<br>
Now in this case is_dir() seems again to be a function, but how come its called differently<br>
</p>
Thanks,<br>
-Kamal.