|
Posted by April on June 19, 2008, 10:41 pm
Please log in for more thread options
For the following program, found somethings seem not seen before, one
is the input <*>, everything and anything? Another is the usage
$i or $i, etc., not sure what that means?
foreach $f (<*>) ( $i = -S $f };
foreach $k (sort{ $i <=> $i$ } keys %i}
{ printf "%8d %s\n", $i, $k }
Any guru can explain? Thanks!
|
|
Posted by Jürgen Exner on June 20, 2008, 12:25 am
Please log in for more thread options
>For the following program, found somethings seem not seen before, one
>is the input <*>, everything and anything?
Another way of writing
glob(*);
> Another is the usage
>$i or $i, etc., not sure what that means?
See
perldoc perldata
and look for hashes. It is retrieving the value of %i for the key that
has the value of $f resp. $b.
jue
|
|
Posted by John W. Krahn on June 20, 2008, 1:44 am
Please log in for more thread options J=FCrgen Exner wrote:
>> For the following program, found somethings seem not seen before, one
>> is the input <*>, everything and anything?=20
>=20
> Another way of writing=20
> glob(*);
ITYM: glob '*';
John
--=20
Perl isn't a toolbox, but a small machine shop where you
can special-order certain sorts of tools at low cost and
in short order. -- Larry Wall
|
|
Posted by Jürgen Exner on June 20, 2008, 4:40 am
Please log in for more thread options >Jürgen Exner wrote:
>>> For the following program, found somethings seem not seen before, one
>>> is the input <*>, everything and anything?
>>
>> Another way of writing
>> glob(*);
>
>ITYM: glob '*';
Hmmm, yes.
jue
|
|
Posted by xhoster on June 20, 2008, 11:13 am
Please log in for more thread options > For the following program, found somethings seem not seen before, one
> is the input <*>, everything and anything?
Yes. There is nothing special about it, it is just the "file glob" version
of the diamond operator, and just happens to have an argument of '*', which
does indeed mean all non-hidden files (in the current directory).
> Another is the usage
> $i or $i, etc., not sure what that means?
%i is a hash. $i is a hash lookup.
> foreach $f (<*>) ( $i = -S $f };
This is storing each file in the hash %i, with the hash key being the
file name and hash value being the file size.
Xho
--
-------------------- http://NewsReader.Com/ --------------------
The costs of publication of this article were defrayed in part by the
payment of page charges. This article must therefore be hereby marked
advertisement in accordance with 18 U.S.C. Section 1734 solely to indicate
this fact.
|
| Similar Threads | Posted | | Directory listing | January 19, 2005, 12:50 am |
| Recursive directory listing | October 8, 2005, 7:32 pm |
| *fastest* was to get a large directory listing in Perl | September 21, 2005, 2:57 pm |
| Size of all files in a directory? | August 7, 2007, 12:45 pm |
| listing all available methods | May 22, 2007, 2:27 am |
| Listing Folders with Net::IMAP | August 19, 2005, 1:28 pm |
| Creating m3u list from opendir listing | April 16, 2005, 8:33 pm |
| Check IP range for DNSBL listing | September 15, 2006, 3:12 am |
| regex: listing all textstrings to be found more that 2 times in a file | January 17, 2005, 9:41 am |
| Screen Size | September 13, 2004, 2:02 pm |
|