Im picking up a project from where another employee left off, and not knowing perl all that well it was a disadvantage that he was a sloppy coder and didnt comment a line of his code. I am trying to finish up a program that will redirect users to a page if the one they are looking for isnt available. But i have a few questions.
if ($Path =~ m{^(.*)\/([^\/]*)})
{
$Dir = $1;
$File = $2;
$Ext=$3;
}
else
{
$File = $Path;
}
if ($File =~ m{^(.*)\.([^\.]*)})
{
$File = $1;
$Dot = ".";
$Ext = $2;
}
else
{
$Dot = "";
$Ext = "";
}
if (-d "/$Dir/$File")
{
$Dir .= "/$File";
$File = "";
}
I cant understand exactly what the first 2 statements do, ive been told the first statement will match anything, because its using the .* operator, but i dont know. If anyone would be so kind as to tell me what the first to pattern matching strings are looking for, i think that would lessen my headache and my extreme hatred for this old programmer!
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.