Okay, I have a functional script now, that writes the code into the flatfile with the record. I will work next on putting it into the html.pl file, to grep the output. But for now...
...and here we go!
In default.cfg, add the following line somewhere in the code:
Code:
@urls = ('http', 'https', 'ftp://');
* You can add or remove any header codes you want. the :// on ftp is a panic code, in case you have "ftp" anywhere else in your text. (i.e., check out my ftp site at...)
In DB.CGI, replace sub validate_record() code with the following:
Code:
push (@input_err, "$col (Invalid date format)") unless &date_to_unix($in{$col});
}
#######################################
# BEGIN Addition #
# Add the following code. You #
# will need to take out the second #
# closing } after the above line, #
# so there is only one }, as shown. #
#######################################
foreach $URL_string (@urls) {
if (lc($in{$col}) =~ /$URL_string/) { # Checks to see if any addresses are in the column
$add1 = (lc($in{$col})); # Gets the entire column record for searching
if ($add1 =~ /$URL_string*(\S+)/i) { # Locates the ENTIRE URL in the string
$replace = "<A HREF=$URL_string$1>$URL_string$1</A>"; # Replacement HTML code
$instance = "$URL_string$1"; # Combines the @urls match to the rest of the address
}
$in{$col} =~ s/$instance/$replace/ig; # Replaces the text address with the HTML code
}
}
}
#######################################
# END Addition #
#######################################
if ($#input_err+1 > 0) { # since there are errors, let's build
...
This works for web addresses only, currently, but can be easily modified for other matches. For example, we have an internal database system at work that I could link to, because the records in that database have a common address. (eg., http://internal.hp.com/data/BPR01121.html, where BPR01121 is the document number, and internal.hp.com/data/ is the common address.) For instances like this, change the following lines:
Code:
@urls = ('http', 'BP', 'ftp');
...
if ($add1 =~ /BP*(\S+)/i) {
$replace = "<A HREF=http://internal.hp.com/data/BP$1.html>Document BP$1</A>";
$instance = "$URL_string$1";
}
if ($add1 =~ /http*(\S+)/i) {
$replace = "<A HREF=$URL_string$1>$URL_string$1</A>";
$instance = "$URL_string$1";
}
if ($add1 =~ /ftp*(\S+)/i) {
$replace = "<A HREF=$URL_string$1>$URL_string$1</A>";
$instance = "$URL_string$1";
}
...
* Notice that because I am looking for a specific URL type, I had to break them into three different matches. Otherwise you will mess up the output. Before, everything is treated the same.
I hope this is helpful, and not too confusing. I can make this into a MOD document, and perhaps someone will find this useful.
[This message has been edited by leisurelee (edited March 09, 2000).]