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!
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
In various use-cases, but especially at web-based registration forms we need to make sure the value we received is
a valid e-mail address. Another common use-case is when we get a large text-file (a dump, or a log file) and we need
to extract the list of e-mail address from that file.
Many people know that Perl is powerful in text processing and that using regular expressions
can be used to solve difficult text-processing problems with just a few tens of characters in a well-crafted regex.
So the question often arise, how to validate (or extract) an e-mail address using Regular Expressions in Perl?
Email validation using Regular Expression in Perl
Normally, if you call a function that does not exist perl will throw an exception Undefined subroutine ... called,
however, unlike in most of the other languages you can define a default function to be called, instead of throwing
that exception. This can give us all kinds of interesting solutions.
Unlike Java, C and similar languages, Perl cannot know at compile time if a function
is going to exist when it is called. Well, actually Perl cannot even know which functions
are going to be called in a given piece of code.
Anyway this means that at run time it might happen that a none-existent function is called.
In such cases normally Perl will die.
AUTOLOAD - handling Undefined subroutines