#!/usr/local/bin/perl -w ### ### generateurltable.lc ### ### This is given a filename which has a number of tab separated ### fields. This is written to the output stream as a table ### of table elements. If there are things which look like ### email addresses, URLs, or image references, they are turned ### into the corrosponding HTML. ### ### This is basically a superset of the generatetable.lc file. ### ### This file should either be in the local directory, or one of ### the system wide webc include directories. ### ### Usage: ### #localcode generateurltable.lc ### #define _TABLE-PARAMS_ border=2 # Optional ### #call GenerateURLTable filename ### ### Dave Regan ### 2 March 2001 ### regan@ao.com ### use strict; use vars qw(%CallFuncs $GenerateURLTableVersion); $GenerateURLTableVersion = 'generateurltable.lc v0.00 regan@ao.com'; ### ### GenerateURLTable ### sub GenerateURLTable { my($fname) = @_; my($field, @fields, $params); if (!open(FILE, "<$fname")) { print STDERR "Cannot open table file $fname: $!\n"; return; } $params = $Symbols{'_TABLE-PARAMS_'} || ""; print OUT "\n"; while () { chomp; $_ = Expand($_); next if (/^\s*$/ || /^\s*#/); @fields = split(/\t+/, $_); print OUT ""; for $field (@fields) { $field =~ s#([-_a-z0-9.%]+\@[-_a-z0-9.%]+?)(\.?\s)#$1$2#gi; $field =~ s#(http://\S+)#$1#g; $field =~ s#(mailto://\S+)#$1#g; $field =~ s#(ftp://\S+)#$1#g; while ($field =~ m#(\S+\.(jpg|gif))# && -f $1) { $field =~ s#(\S+\.(jpg|gif))##; } print OUT "\n"; } print OUT "\n"; } print OUT "
$field
\n"; close FILE; return ""; } ### ### Linkage to the main program ### $CallFuncs{'GenerateURLTable'} = 1; return 1;