Home Accessibility Courses Twitter The Mouth Facebook Resources Site Map About Us Contact
 
For 2023 (and 2024 ...) - we are now fully retired from IT training.
We have made many, many friends over 25 years of teaching about Python, Tcl, Perl, PHP, Lua, Java, C and C++ - and MySQL, Linux and Solaris/SunOS too. Our training notes are now very much out of date, but due to upward compatability most of our examples remain operational and even relevant ad you are welcome to make us if them "as seen" and at your own risk.

Lisa and I (Graham) now live in what was our training centre in Melksham - happy to meet with former delegates here - but do check ahead before coming round. We are far from inactive - rather, enjoying the times that we are retired but still healthy enough in mind and body to be active!

I am also active in many other area and still look after a lot of web sites - you can find an index ((here))

Well House Consultants
You are on the site of Well House Consultants who provide Open Source Training Courses and business hotel accommodation. You are welcome to browse and use our resources subject to our copyright statement and to add in links from your pages to ours.
Other subject areas - resources
Java Resources
Well House Manor Resources
Perl Resources
Python Resources
PHP Resources
Object Orientation and General topics
MySQL Resources
Linux / LAMP / Tomcat Resources
Well House Consultants Resources
Extras Resources
C and C++ Resources
Ruby Resources
Tcl/Tk Resources
Web and Intranet Resources
Perl module P602
Advanced File and Directory Handling
Exercises, examples and other material relating to training module P602. This topic is presented on public courses Perl for Larger Projects, Extra Day

File locking, database file handling, directory manipulation and more. This module also covers Perl's format and write commands used for traditional text formatting applications, but now of specialist interest.

Related technical and longer articles
File Locking

Articles and tips on this subjectupdated
3429Searching through all the files in or below a directory - Ruby, Tcl, Perl
Many of our customers want to learn how to traverse all the files in a directory, or perhaps even all the files in or below a directory. I quite often write a demonstration program during our courses which looks though part of a file system tree for files over a certain size, or for the largest (so ...
2011-09-09
 
3412Handling binary data in Perl is easy!
Perl can handle binary data just as easily as ASCII text - but YOU - if you're the programmer - must understand the format of the data that you'll be working with. With binary data it's every bit as important to get the right bytes in the right places as it is to get the appropriate separators between ...
2011-08-30
 
2876Different perl examples - some corners I rarely explore
The private Perl course that I ran on Wednesday through Friday of last week was a little out of the ordinary as we were concentrating far more that usual on a wide variety of practices that may be found - either in legacy code or advanced recent code. Great fun for me, and plenty of new examples. Here ...
2010-12-04
(longest)
1832Processing all files in a directory - Perl
From this week's Perl course: opendir(DH, "."); while ($igot = readdir(DH)) {   next if ($igot =~ /^\.{1,2}$/);   print "igot $igot\n"; } You'll notice that I have used a regular expression to check for files called dot and dot-dot, which are the current and parent directory, as ...
2010-06-23
 
1861Reactive (dynamic) formatting in Perl
If you want to format your data neatly in columns, you can use sprintf or printf to do so if you're using a fixed width font. A format of "%20s", for example, calls for a string that's 20 characters long and will be trailing space padded ... except ...that figure "20" is a minimum width, and if your ...
2008-10-31
 
1709There is more that one way - Perl
"There are six ways of doing anything in Perl." So say I on Perl courses and just occasionally I come up with an example that proves it. This one doesn't quite - I show you just five ways of finding the names of all the files in the current directory: $stuff = `ls`;   @fings = glob("*");   opendir(DH,"."); @allfings ...
2008-07-23
 
1225Perl - functions for directory handling
Perl has many built in functions for file and directory handling and you should use them in preference to shelling out in your scripts because: • They work across operating systems (at least as far as is practical) • They are much more efficient as there's no extra processes being started ...
2007-06-12
 
975Answering ALL the delegate's Perl questions
During courses, questions arise. "I'll get back to that" could make people feel that I'm brushing something off ... except that I explain, early on, that some questions require a great deal of background knowledge to be answered sensibly. And I keep a list of topics that I'll be getting back to ...
2006-12-09
 
839Reporting on the 10 largest files or 10 top scores
What are the biggest 10 files in or below this directory? What are the 20 'worst' spams I have received in the last month? What are the five top scores recorded for a popular game on my web site? It's a very common requirement indeed to provide a program to answer questions like these, and if you've ...
2006-08-19
 
Examples from our training material
bchop   Random access to a file - using a binary chop
biggest   Look for biggest files in a tree
flockdemo   Co-operative file locing with flock
ftype   Establishing the type of a file system object
huge   finding lost disc space - hunting for huge files
huge2   A progress line - hunting for huge files
loglook   reading a specific number of bytes
ndd   Accessing NDBM files
nf   Use of $! to find out why an action failed
nopen   $! in a string and a numeric context
pfc   Copying a file block by block
pls   Four ways of finding the contents of a directory
recur   recursively scanning directories
webfiles   Using typeglobs to handle an effective array of files
wr_loop   Using file locking constants
Background information
Some modules are available for download as a sample of our material or under an Open Training Notes License for free download from [here].
Topics covered in this module
Basic file handling.
Opening files.
Reading from file.
Writing to file.
Enquiring about a file.
Other uses of the file interface.
Arrays of file handles.
Directory Handling.
Going recursive.
Random access files.
An example using a sorted, fixed-length record file.
File Locking.
Alternative schemes.
Database files.
Built-in file system handlers.
Complete learning
If you are looking for a complete course and not just a information on a single subject, visit our Listing and schedule page.

Well House Consultants specialise in training courses in Ruby, Lua, Python, Perl, PHP, and MySQL. We run Private Courses throughout the UK (and beyond for longer courses), and Public Courses at our training centre in Melksham, Wiltshire, England. It's surprisingly cost effective to come on our public courses - even if you live in a different country or continent to us.

We have a technical library of over 700 books on the subjects on which we teach. These books are available for reference at our training centre.


You can Add a comment or ranking to this page

© WELL HOUSE CONSULTANTS LTD., 2024: 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01144 1225 708225 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho

PAGE: http://www.wellho.net/resources/P602.html • PAGE BUILT: Sun Oct 11 14:50:09 2020 • BUILD SYSTEM: JelliaJamb