Link to home
Start Free TrialLog in
Avatar of Caiapfas
Caiapfas

asked on

I need output with this script to display how many links for each <!-- -->

I need this script to display how many <! whatever, whateevr --> after it's done indexing/adding the links...i casued all kinds of errors..


#!/usr/bin/perl

# $dir is the directory with the html pages (e.g. c:\\concert)
# $wdir is a path the path to be inserted in the URLs (e.g. /whatever/concerts)
# $indextpl is the index template file (e.g. C:\\test\\index.tpl)
# $indexhtm is the final index file (e.g. c:\\test\\index.htm)
# The script has been tested under unix. For WIn32 you might need to change the slashes in paths from / to \\, and also the perl path in the first
# line.

$dir="C:\\web\\ticketstogo.com\\venues";
$wdir="http://www.meme.com/venues";
$indextpl = "C:\\web\\venues\\states\\tempindex.htm";
$indexhtm = "C:\\web\\venues\\states\\aindex.htm";

# read venue files
opendir(DH, $dir) or die "Can't open $dir for reading: $!";
while(defined($file=readdir(DH))) {
  next unless $file =~ /\.htm$/i;
  open(FILE, "<$dir/$file") or die "Can't open $file for reading: $!";
 # $ven{$1}{$2} = "$wdir/$file" if <FILE> =~ /^\<\!-- (.*), (.*) --\>$/;
    $ven{lc($1)}{$2} = "$wdir/$file" if <FILE> =~ /^\<\!-- (.*), (.*) --\>$/;
  close(FILE);
}

# process template
open(STDIN, "<$indextpl") or die "Can't open $indextpl for reading: $!";
open(STDOUT, ">$indexhtm") or die "Can't open $indexhtm for writing: $!";
while(<>) {
  if(/^\<\!-- (.*) --\>$/) {
#   print map {"<A href=\"$ven{$1}{$_}\">$_</A><BR>\n"} sort keys %{$ven{$1}};
     print map {"<A href=\"$ven{lc($1)}{$_}\">$_ event tickets</A><BR>\n"} sort keys %{$ven{lc($1)}};
  } else {
    print;
  }
}
Avatar of Caiapfas
Caiapfas

ASKER

I'm trying to make the script , display how many links for each catogroy now..
example : it found and linked 300 <!-- whatever, Texas -->

Show after its done it makes a text file and says...

Index/Linked :

300 : Texas
200 : whatever
1000 : whatever also
but leaving the script so, that it will work with <!-- AnYtHinG, WhaTEvEr -->
ASKER CERTIFIED SOLUTION
Avatar of lbertacco
lbertacco

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
God, you are the man!
I have learned so much...I'm taking the scripts and adding and using them in so many app.
jezz...my goal is to be a fluent as you in scripts..
big a++ kiss , but dang you deserve it for the knowledge you have..
oo yea one last thing can we make it tell the grand total and how many it had to dump, due to no home?
and with the dumps, make it dump to a text file ..in link format, so cut n paste is easy...I still dont know how to make a text file with perl


I can open another question, if this is off topic
i installed activeperl for this, and i have QUICK questions about it.

Can I run perl app. for my browser?that is located on my pc?
Glad that you can make good use of these script examples.
You can run perl apps on your (winodws) pc with activeperl, but to do it from a browser you also need to install a webserver which supports CGI and activeperl  (e.g. microsoft IIS ($) or Apache (free)). Also inthe case of IIS, it's better if you first install IIS and then Activeperl.
I'll work on the dump thing as soon as I have a few minutes to spare, but I think you should open another question.
the new question
https://www.experts-exchange.com/questions/20941490/Output-and-page-creation-from-html-pages-and-a-template-PERL-would-mind-making-it-in-javascript.html


and afew quick questions about microsoft IIS,

its basiclly a webserver software right? where i could host a website on my pc?
if so what is the best software to do this?
what other software do you need with microsoft IIS  to run a good webserver?