Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much

Re: count files in a directory

by manuelsv (Initiate)
on Oct 10, 2011 at 11:51 UTC ( #930596=note: print w/replies, xml ) Need Help??

in reply to count files in a directory

Maybe a more concise approach, using globbing ?

#!/usr/bin/perl use strict; use warnings; my $dir = '/home/oracle/test/Oracle/oradata'; my @files = <$dir>; my $numfiles = scalar @files; print "Files in $dir: $numfiles\n";
Hope it helps.

Replies are listed 'Best First'.
Re^2: count files in a directory
by Anonymous Monk on Oct 10, 2011 at 11:59 UTC
    It might work if you add
    chdir $dir or die "Cannot chdir to '$dir': $!"; my @files = glob '*';

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://930596]
[Lady_Aleena]: choroba, the tables in that group of modules is from the World Builder's Guidebook, so I thought it best to add the name of the book to the name of the module.
[choroba]: oh, I see
[Lady_Aleena]: There is the RolePlaying:: WorldBuilding:: WorldBuildersGuide book suite and the RolePlaying:: WorldBuilding:: HighLevelCampaigns suite.

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (9)
As of 2017-05-24 22:28 GMT
Find Nodes?
    Voting Booth?