sjh - mountain biking running linux vegan geek spice - mtb / vegan / running / linux / canberra / cycling / etc

Steven Hanley hackergotchi picture Steven
Hanley

About

email: sjh@svana.org

web: https://svana.org/sjh
twitter: https://twitter.com/sjhmtb
instagram: https://instagram.com/sjhmtb

Other online diaries:

Aaron Broughton,
Andrew Pollock,
Anthony Towns,
Chris Yeoh,
Martijn van Oosterhout,
Michael Davies,
Michael Still,
Tony Breeds,

Links:

Linux Weekly News,
XKCD,
Girl Genius,
Planet Linux Australia,
Bilbys,
CORC,

Canberra Weather: forecast, radar.

Subscribe: rss, rss2.0, atom

March
Mon Tue Wed Thu Fri Sat Sun
 
28      

2005
Months
Mar

Categories:

Archive by month:

Mon, 28 Mar 2005

Faster directory reading - 20:13
I suppose if Jeremy is responding to some of Mikal's perl it will not hurt to also.

Mikal asks if there is a faster way to read a directory than using open and ls and stuff. This reminds me of a buttload entry a bit

<Schwern> Are we using perl to generate a shell script?
<Schwern> Its like building a bridge across a canyon so you can tie a rope and cross with that.

Anyway with perl and TMTOWTDI the answer is yes you can do this faster. Michael, the simplest way is simply using opendir and readdir, if you look at the documentation in "perldoc -f readdir" you can probably see an example. Using native perl is always going to be faster than launching a separate shell (which you probably realise, explaining why you wondered if there is some faster way).

Of course looking at the things you have been asking today I wonder if the perl module File::Find may help you out with doing some of the stuff you need.

[/comp/software] link


home, email, rss, rss2.0, atom