Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: working with directories

by tobyink (Canon)
on Sep 12, 2013 at 12:03 UTC ( [id://1053702]=note: print w/replies, xml ) Need Help??


in reply to working with directories

Your while loop is pretty useless.

while (@folder = readdir(DIR)){ last; }

... is basically a convoluted way of writing:

@folder = readdir(DIR);

Generally speaking, I'd recommend Path::Tiny as a much easier way of dealing with files and directories than Perl's built-ins.

use Path::Tiny 'path'; my $dir = path('/Users/Maxi/Desktop/Verzeichnis beispiel'); for my $file ($dir->children) { next if $file->is_dir; my $fh = $file->openr; while (my $line = <$fh>) { ...; } }
use Moops; class Cow :rw { has name => (default => 'Ermintrude') }; say Cow->new->name

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1053702]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (5)
As of 2024-04-20 11:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found