What can you do here?
If you are a beginner, or would like to refresh your Perl programming knowledge,
you can go over the Perl tutorial.
You will find a few advanced articles too, though most of the advanced articles are available to the
subscribers of the Perl Maven Pro service only.
If you are interested to listen to or even see other Perl developers,
the Perl Maven TV Show is a collection of such interviews.
Want to make sure you don't miss any of the Perl Maven articels?
Sign up to the newsletter!
If we would like to know the list of file and other things in a given directory we could use the external ls
command, but that would make our code platform dependent - Windows has the dir command for directory listing -
and it would create an an unnecessary execution of an outside command. Instead of that Perl provide two alternatives.
One of the is called file globbing, and it is usually useful if we are interested in certain subset of files (e.g. all
the files with xml extension), the other one is using the manual opendir function with readdir and closedir.
Reading the content of a directory
I used to work on an application where we wanted to let non-developers, and even managers to be able to provide input to our system
in batches. We did not want them to fill a web form, as those usually have rather limited editing capabilities.
They were already familiar with Microsoft Excel, so letting them use that and send us the Excel files looked like a good way
to get them involved.
Then we faced the issue, of given a file created by Microsoft Excel, how can we read the content while running on a Linux machine
running Red Hat, or on a Solaris box.
How to read an Excel file in Perl
Using regular expressions provides us with enormous power but reading and understanding
complex regular expressions is not an easy task. I noticed, for many people,
it feels much easier to write a regular expression than to read it.
This is probably true regardless of the host language but in Perl
we tend to use regexes much more than in other languages.
Understanding Regular Expressions found in Getopt::Std