Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical

Re: count files in a directory

by reisinge (Friar)
on Oct 10, 2011 at 11:07 UTC ( #930586=note: print w/replies, xml ) Need Help??

in reply to count files in a directory

To count the number of files in mydir you could use:
#!/usr/bin/perl use strict; use warnings; my $dirname = "/mydir"; opendir ( DIR, $dirname ) || die "Error in opening dir $dirname\n"; my $count; while ( (my $filename = readdir(DIR)) ) { next if $filename =~ /^\.{1,2}$/; # skip . and .. $count++; } closedir(DIR); print "$count files live in '$dirname'\n";

Update: a sample mail sending code.

Have a nice day, j

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://930586]
Discipulus shall be damned all progs that do not provide different font size!
[Corion]: Yeah - that's one important thing why I like to run my presentations from my browser. Ctrl+ and Ctrl- are incredibly helpful there to make sure everybody can read stuff
[Discipulus]: I 'm always at 125%, and fontsize 12

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (10)
As of 2017-09-26 09:30 GMT
Find Nodes?
    Voting Booth?
    During the recent solar eclipse, I:

    Results (293 votes). Check out past polls.