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 P215
More about Files
Exercises, examples and other material relating to training module P215. This topic is presented on public course Perl for Larger Projects

You can do much more with files in Perl than just read or write text from and to them. This module covers checking on file size and status, checking all the files in a directory, handling binary data and more. It also covers file system management functions that let you create and delete files and directories, and change permissions on them.

Related technical and longer articles
Solution Centre - all article listing
Solution Centre - all article listing
Writing to and reading from files

Articles and tips on this subjectupdated
3839Spraying data from one incoming to series of outgoing files in Perl
Scenario. I have a lot of data that contains large numbers of records which I want to separate into groups. For example, an incomeing web server log file which I want to split out and process visitor by visitor. Using Perl, I can loop through my data line by line and store it into a hash - for example:     while ($lyne ...
2012-08-18
 
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
 
3320Reading the nth line from a file (Perl and Tcl examples)
"How do I find the 100th line in a file" - a common question for newcomers to coding. The short answer is to open the file, and loop through to read lines until the one that you want. Although most languages have a seek command or function, that works by bytes and with a typical text / ascii file, ...
2011-06-09
 
2964An introduction to file handling in programs - buffering, standard in and out, and file handles
Stdout and Stderr Programmers typically don't write code to output to the screen / current window, as to to so would be to provide an inflexible system - instead, they output to what's known as "standard out", also known as stdout. Usually stdout defaults to the screen / current window so there's no ...
2010-09-21
(longer)
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
 
2405But I am reading from a file - no need to prompt (Perl)
If you're writing a script that calls for user input, you had better prompt the user ... otherwise, the terminal / window will appear to hang and the user won't know what's going on. However - if you're reading your answers from a pre-prepared file or piping them in from another process, all of these ...
2010-06-23
 
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
 
Examples from our training material
ab_file   Using some of the file status operators
af   using the stat function to report on a file
allin   Read and report contents of a directory
chdirddemo   Using directory functions cwd, chdir, opendir, readdir
dend   Data on end of program file
dotty   globbing on a file handle
dxyz   Finding all files with names matching a pattern
f2   Formatting using "format" and "write"
fal   split an incoming file lots of ways
file   _ and $_ in file operators
ft   testing file existence, size and other stats
hunt   Random access to a file of fixed length records
inter   See is STDIN is interactive, and prompt if it is
lowther.pl   Reading data from the end of the program file
segment   Spray one input file across 16 different outputs
whatsmypath   Lists out all duplicate executables
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
Other file status requests.
Operators.
globbing.
stat.
File locking, random access files, etc.
File locking.
Random access file.
Accessing the file system.
Including data within your programs.
Here documents.
Reading from the end of your program.
Formatted write.
Summary.
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.info/resources/P215.html • PAGE BUILT: Sun Oct 11 14:50:09 2020 • BUILD SYSTEM: JelliaJamb