Bill,

Thanks for all your work, sometimes someone sees beyond what others see.

Malcolm
----- Original Message -----
From: "$Bill Luebkert" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: 17 March 2002 03:19
Subject: Re: Looping


> Malcolm Debono wrote:
>
> > Thank you all for the support.
> >
> > The problem was using the same file handle about 4 times.
>
>
> I caught that, but that's just part of the problems.  I reformatted
> and inserted some comments/questions with ##.  Some further explanation
> of what you are doing would help.
>
>
> # The intention is to stop auto-submit to every page so that it stops
> # duplicating postings and my ISP charging for extra bandwidth.
>
> ## what's auto-submit ?
> ## How do you get duplicate postings ?  Postings to what ?
> ## Now sure how this relates to bandwidth.
>
> use strict;
>
> my $has_flock = 1;
>
> # This opens the file that has been submitted on original
>
> ## Submitted how ?  On original what ?
> ## How about a sample of file data ?
>
> open FORM, 'submit.dat' or die "Can't open file : $!";
> my @ary = <FORM>;
> close FORM;
>
> my ($userdir, $title, $url, $sectiona);
> foreach my $line (@ary) {
>
> chomp $line;
> ($userdir, $title, $url, $sectiona) = split /\|/, $line;
>
> ## there's no code in this loop - what is it for ?
> }
>
> # This opens the forms list
>
> ## How about a sample of file data ?
>
> open FILE, "<list.dat" or die "Can't open file: $!";
> while (my $list = <FILE>) {
> chomp $list;
> &mysub ($list);
> }
>
> print "I am done\n";
> exit;
>
>
#- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 -
>
> sub mysub {
> my $list = shift;
> my %sections = ("busi" => "Business", "comp" => "Computers",
>   "educ" => "Education", "ente" => "Entertainment",
>   "govt" => "Government", "pers" => "Personal",
>   "misc" => "Miscellaneous");
> my @months = qw(January February March April May June July August
>   September October November December);
> my @days = qw(Sunday Monday Tuesday Wednesday Thursday Friday Saturday);
> my $home = 'http://yes/lnks';
> my $basedir = 'C:/Inetpub/wwwroot/lnks';
> my $baseurl = 'http://yes/lnks';
> my $lnkuser = $list;
> my $linkscgi = 'http://yes/cgi-bin/userlinkpage/ezlinknu.pl';
> my $linksurl = "$baseurl/$lnkuser.html";
> my $linkstitle = "FREE FOR ALL - UNITED KINGDOM";
> my $filename = "$lnkuser.html";
> my $database = "$basedir/$lnkuser.db";
>
> # This opens the form details
> ## How about a sample of file ?
>
> open FILE, "$basedir/$lnkuser.dat" or
>    die "I can't open $basedir/$lnkuser.dat\n";
>
> ## FILE still in use in calling routine !!
>
> if (not $has_flock) { flock (FILE, 1) or die "Can't lock datafile for
edit\n"; }
>
> # reusing $lnkuser here in loop:
>
> #my ($usrname, $email, $headline, $lnkuser, $colorset, $maxitems, $mail,
> my ($usrname, $email, $headline, $colorset, $maxitems, $mail,
>    $remote_mail, $subject, $ltrtext, $retlink);
> while (<FILE>) {
>
> chomp;
> my @datafile = split /\n/;
>
> foreach my $line (@datafile) {
>
> ($usrname, $email, $headline, $lnkuser, $colorset, $maxitems,
>   $mail, $remote_mail, $subject, $ltrtext, $retlink) =
>   split /&&/, $line;
> }
> }
> close FILE;
>
> # This adds info
>
> ## How about a sample of file data ?
>
> open FILE, "$basedir/$filename" or die "Can't open file : $!";
> my @lines = <FILE>;
> close FILE;
>
> foreach my $line (@lines) {
>
> if ($line =~ /\<li\>\<a href\=\"([^\"]+)\">([^<]+)<\/a>/) {
> if ($url eq $1) {
> &repeat_url;
> }
> }
> }
>
> # Open Link File to Output
>
> open FILE, ">$basedir/$filename" or die "Can't open file : $!";
>
> my $p = 0;
> my $items = 0;
> foreach my $line (@lines) { # For every line in our data
>
> if ($line =~ /<!--time-->/) { # output link time
>
> my @t = (localtime)[0..6];
> my $date = sprintf "on %s, %s %02u, %4u at %02u:%02u:%02u",
>   $days[$t[6]], $months[$t[4]], $t[3], $t[5]+1900, $t[2],
>   $t[1], $t[0];
> print FILE "<!--time--><b>Last link was added $date</b><hr>\n";
>
> } elsif ($p == 0) { # line not in block - check for begin block
>
> if ($line =~ /<!--begin-->/) {
> print FILE "<!--begin-->\n";
> $p = 1;
> } else {
> print FILE $line;
> }
>
> } elsif ($p == 1) { # line in block - check for sub or end block
>
> if ($line =~ /<!--end-->/) {
>
> print FILE "<!--end-->\n";
> $p = 2;
>
> } elsif ($line =~ /<!--/) { # handle tag blocks
>
> print FILE $line;
> $items = 0;
>
> foreach my $tag (keys %sections) { # For every tag
>
> if ($sectiona eq $sections{$tag} and
>   $line =~ /<!--$tag-->/) {
> $items++;
> print FILE
>   "<li><a href=\"$url\">$title</a>\n";
> ## $sectiona, $url and $title are constants in this section - not right
> }
> }
> } elsif ($line =~ /^<li><a href=/) { # handle max hrefs
>
> $items++;
> if ($items <= $maxitems) {
> print FILE $line;
> }
> } else { # else just print line
> print FILE $line;
> }
>
> } elsif ($p == 2) { # lines after block are just printed
>
> print FILE $line;
> }
> }
>
> close FILE;
>
> # Return Link File
> # print "Location: $linksurl\n\n";
>
> #This is to see if it reads all the variables on the list
> print "This is the variable list $list\n";
>
> }
>
> sub repeat_url { exit; }
>
> __END__
>
>
> --
>    ,-/-  __      _  _         $Bill Luebkert   ICQ=14439852
>   (_/   /  )    // //       DBE Collectibles   Mailto:[EMAIL PROTECTED]
>    / ) /--<  o // //      http://dbecoll.tripod.com/ (Free site for Perl)
> -/-' /___/_<_</_</_     Castle of Medieval Myth & Magic
http://www.todbe.com/
>
> _______________________________________________
> Perl-Win32-Users mailing list
> [EMAIL PROTECTED]
> To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
>

_______________________________________________
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to