if($l =~ m/([012]?[0-9]):([0-5][0-9])(:[0-5][0-9])?\s*([a-z0-9.+-]+)/i
&& is_ampm($4))
will catch 06:20:00 AM, 06:20AM, 05:30 EDT, 13:32 GMT+0500,
and 07:15 a.m., split out the hours, minutes, seconds, and timezone,
and pass the timezone to
a is_ampm() function for verification.
- String modification is also powerful. For instance,
s/\b(brows\w+)/fiddle($1)/eg;
will find words beginning with 'browse', feed them into a function
fiddle()
,
and substitute the output of fiddle
back
into the string.
- Database access is built in.
The
tie()
function can connect an associative array
to a database package, so that array references are transparently
mapped into database accesses. For instance,
tie(%h, GDBM_File, "database_filename", &GDBM_READER, 0600);
if( $h{$username, likes_spaghetti} ) {
print "$username likes spaghetti\n";
}
untie(%h);
is a minimalist program to access a database_filename
to find out if someone likes spaghetti.
The array reference -- $h{xxx} -- gets mapped into
a lookup of the value associated with the key 'xxx'.
- ...