[6478] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 103 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Mar 12 14:27:24 1997

Date: Wed, 12 Mar 97 11:00:27 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Wed, 12 Mar 1997     Volume: 8 Number: 103

Today's topics:
     Re: 10 commandments (was re: Which one is the best (pat (Sitaram Chamarty)
     Re: 2way socket communications <tchrist@mox.perl.com>
     a tricky regex <bryan@eai.com>
     Re: All I want to do is subtract 180 days from a given  (Paco Hope)
     Am I hosed? (Can't compile modules) (Ross Carlson)
     Can anyone help w/cgi scripting problem? (Greg Smith)
     Re: Chopping lines? (Joel Earl)
     Elegant way to strip spaces off the ^ and $ of a variab (Sherman Hsieh)
     exec & nohup <gjsincla@tddcae99.fnts.com>
     Help with "waitfor.pl" <eermmb@engunx.unl.edu>
     How do I get all more than 2 hours old files <rbhatt@netscape.com>
     Re: MacPerl5 <eike.grote@theo.phy.uni-bayreuth.de>
     Perl 5.003 on Solaris 2.4 (Lars Oberg)
     Re: Perl FAQ part 8 of 0..9: System Interaction [Period <monnier@cs.yale.edu>
     Perl Interpretors <cooper15@hsonline.net>
     Re: Perl Interpretors (A. Deckers)
     Re: Signal catching with alarm <mtk@ny.ubs.com>
     year 2000 question (Dan Ellsweig (Enterprise Management))
     Re: year 2000 question <jhi@alpha.hut.fi>
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Wed, 12 Mar 1997 13:37:13 GMT
From: sitaram@diac.com (Sitaram Chamarty)
Subject: Re: 10 commandments (was re: Which one is the best (pattern matching))
Message-Id: <3326b132.78443220@news.diac.com>

Tom Christiansen <tchrist@mox.perl.com> wrote:

> [courtesy cc of this posting sent to cited author via email]
>
>In comp.lang.perl.misc, 
>    dbenhur@egames.com writes:
>:> 9) Thou shall check return stati of functions
>
>Oh boy, two grammatical errors in one sentence.
>
>    1) The second person of shall is shalt (well, to my ear; the OED
[10+ lines of detailed description of "declensions", etc snipped]
>
>--tom

WOW!  And I thought Larry was the linguist :-)


------------------------------

Date: 12 Mar 1997 16:44:40 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: 2way socket communications
Message-Id: <5g6mho$71s$3@csnews.cs.colorado.edu>

 [courtesy cc of this posting sent to cited author via email]

In comp.lang.perl.misc, 
    ldadams@mindspring.com writes:
:1. I read the camel book
:2. I read the faq's
:3. I read the perlipc
:4. I read several other sources(Cross Platform Perl, ...)
:5. If I missed what I need in the above, please point out my blindness
:
:What I want to do (and I'm not an expert on programming with sockets):
:
:machineA: server to take requests and pass back info
:machineB: client to request items 1,2,3 from server
:machineC: client to request items 3,4,5 from server
:
:My biggest problem is in handling the 2way exchange. I have written
:clients and servers basically mimicing the scripts in the above sources
:and they work. Those are mostly reactionary from a basic level, and the
:server automatically spits back some predetermined data. 

The basic problem with full-duplex communication is having both sides
agree on when the other has stopped sending.  Hence the lone dot thing
with SMTP, NNTP, etc.  You have to invent a protocol so that the server
knows when it's read the whole request in (limiting it to a line is
probably easiest) and so that the client know when the it has read
everything from the server.  You'll have to invent a record separator,
or prefix the record with its length.

Here's a semi-trivial example from part 5 of the new FAQ:

    use IO::Socket;		  # this one is kinda a pipe?
    $sock = IO::Socket::INET->new(PeerAddr => 'www.perl.com',
				  PeerPort => 'http(80)',
				  Proto    => 'tcp'       );
    die "$!" unless $sock;

    $sock->autoflush();
    $sock->print("GET /\015\012");
    $document = join('', $sock->getlines());
    print "DOC IS: $document\n";


--tom
-- 
	Tom Christiansen	tchrist@jhereg.perl.com
     "... an initial underscore already conveys strong feelings of
      magicalness to a C programmer."
	--Larry Wall in <1992Nov9.195250.23584@netlabs.com>


------------------------------

Date: Wed, 12 Mar 1997 12:15:30 -0600
From: Bryan Hart <bryan@eai.com>
Subject: a tricky regex
Message-Id: <3326F2C2.1B38@eai.com>

Sorry for asking such a question here, but I'm getting a bit stumped. 
I'm looking for a regex (or some other way) to remove whitespace from a
string EXCEPT when the whitespace is enclosed in quotes("").

Here's an example string:

$Footer = { PullDown["New Issue"(AddNewIssue), "Help"(Help), "Issue
Sticky"(StickyIssueAdd), "Link Sticky"(StickyLinkAdd)]; Motion;
PullDown[ "Format 1"(Layout<1>), "Format 2"(Layout<2>), "Format
3"(Layout<3>), "Default"(Layout<0>)] }

Bryan
-- 
-------------------------------
|  Bryan Hart                 
|  Network Products Engineer  
|  Engineering Animation Inc. 
|  Phone: (515) 296-5979
|  Fax: (515) 296-7025
|  Email: bryan@eai.com              
|  Web: http://www.eai.com/                          
-------------------------------
"A conclusion is simply the place where you got tired of thinking"


------------------------------

Date: Wed, 12 Mar 1997 16:42:09 GMT
From: bah6f@cs.virginia.edu (Paco Hope)
Subject: Re: All I want to do is subtract 180 days from a given date!
Message-Id: <5g6md1$1dc@jazz.cs.Virginia.EDU>


In article <nnh4g5.143.ln@localhost>, tadmc@flash.net (Tad McClellan) writes:
> : User inputs a date, and gets a date 180..0 days earlier. 
>   ^^^^^^^^^^^^^^^^^^

You want the Date::DateCalc library.  Get it from  a CPAN site.
I use:
ftp://uiarchive.cso.uiuc.edu/pub/lang/perl/CPAN/modules/by-module/Date

This allows you to take dates in a wide variety of formats, and
manipulate them in a wide variety of useful ways.

If you had the user's input in $datestr, then you would
use the following tidbits to do exactly what you want:

use Date::DateCalcLib qw( decode_date_us );
use Date::DateCalc    qw( calc_new_date  );

$offset = -180;

($yy, $mm, $dd)		 = decode_date_us( $datestr );
($newyy, $newmm, $newdd) = calc_new_date( $yy, $mm, $dd, $offset );

$newdatestr = date_to_string( $newyy, $newmm, $newdd );

print "180 days ago: $newdatestr\n";


Cheers,
Paco
-- 
Paco Hope                                         Computer Systems Engineer
paco@cs.virginia.edu                         Department of Computer Science
http://www.cs.virginia.edu/~bah6f/                   University of Virginia


------------------------------

Date: Wed, 12 Mar 1997 18:41:06 GMT
From: webmaster@metacraft.com (Ross Carlson)
Subject: Am I hosed? (Can't compile modules)
Message-Id: <3326f837.0@news.together.net>

Hello all,

I have an SGI Indy Webforce workstation that came very
bare bones, and without the SGI developer's package.
As a result, I have no compiler! (ARGH)

Lately I have been trying to make use of some of the 
perl modules on CPAN, and it seems that they need to
be compiled. Am I hosed?

I am currently putting together a reporting system for
my clients web sites. I need to be able to parse through
common web server logs quickly, breaking up each hit
into its component parts. I have been able to do this with
standard pattern matching, but it just feels like there must
be a better way.

I also need to be able to take the date string from each
hit in the web server logs and convert it into the integer
format returned by the Perl time() function. Many of you
have suggested some of the date manipulation modules
on CPAN, but then I have the compiler problem again.

The other deal is that I would like the log parsing scripts
to be able to run on a Windows 95 machine if possible.

Anyway, the SGI is an Indy, running IRIX 5.3, and my 
perl interpreter is versino 5.001. Some kind soul on this
newsgroup sent me that binary a few months ago.

Thank you in advance for any suggestions that anybody
might have!

Ross A. Carlson
___________________________________

    Metacraft Internet Services
      webmaster@metacraft.com
     http://www.metacraft.com
      The Real Estate Guide:
      http://www.nehomes.com
___________________________________

Eat healthy, stay fit; die anyway.


------------------------------

Date: 12 Mar 1997 17:18:05 GMT
From: bdp@microweb.com (Greg Smith)
Subject: Can anyone help w/cgi scripting problem?
Message-Id: <bdp-1203970921140001@wolfgang.vip.best.com>

Hello,

Any help that more experienced cgi/perl scripters can offer will be very
much appreciated. This is my first attempt at modifying a cgi script that
accesses information from a text log file so I aplogize if this is a
newbie question. 

I have a counter running on my site that creates a text log file in which I run
a second cgi script to access that data which displays the data in a
browser. I'm trying to modify the script to display "hits by month" in
addition to the already scripted routines.

I cannot seem to figure out what the call or proper syntax is for the
month routine to operate properly. Currently I've modified the script to
set up the table for the data with the months in proper order, but no data
is processed. I created the array (Lines 50 to 52 - see below) for the
months and it seems to be working, but I cannot get the script to compile
the actual hits by month. Any thoughts? The script is running at
www.voxshowroom.com/cgi/vsr_log.cgi. The script calls to a data file in a
logs directory in my public_html directory.

I suspect that the script as it stands is not actually getting this
information and so my $mon call to the text log is returning empty
information.
 

Thanks in advance,
Greg Smith

----

The text log file the script calls looks like this:

----

[15:21:42 11/28/96 4]
http://www.asmalladshop.com/design/illustration/amazon/woman.htm -
152.169.117.21 -  Mozilla/2.02 (Win16; I)

[15:21:56 11/28/96 4]
http://www.asmalladshop.com/design/illustration/amazon/woman.htm -
152.169.117.21 -  Mozilla/2.02 (Win16; I)

[15:22:36 11/28/96 4]
http://www.asmalladshop.com/design/illustration/amazon/woman.htm -
152.169.117.21 -  Mozilla/2.02 (Win16; I)

[16:37:18 11/28/96 4]
http://www.asmalladshop.com/design/illustration/amazon/woman.htm -
152.169.117.21 -  Mozilla/2.02 (Win16; I)

----

The script is as follows: I created the Month routine at lines 399 to 409
and the month array at lines 50-52, which I suspect is empty at this
point.

----

#!/usr/local/bin/perl
##############################################################################
# HTML Log                      Version 1.0                                  #
# Copyright 1996 Matt Wright    mattw@worldwidemart.com                      #
# Created 10/25/95              Last Modified 10/26/95                       #
# Scripts Archive at:           http://www.worldwidemart.com/scripts/        #
# The file STAT_README contains more information. For Use With Counter 1.1.1 #
##############################################################################
# COPYRIGHT NOTICE                                                           #
# Copyright 1996 Matthew M. Wright  All Rights Reserved.                     #
#                                                                            #
# HTML Log may be used and modified free of charge by anyone so long as      #
# this copyright notice and the comments above remain intact.  By using this #
# code you agree to indemnify Matthew M. Wright from any liability that      #
# might arise from it's use.                                                 #
#                                                                            #
# Selling the code for this program without prior written consent is         #
# expressly forbidden.  In other words, please ask first before you try and  #
# make money off of my program.                                              #
#                                                                            #
# Obtain permission before redistributing this software over the Internet or #
# in any other medium.  In all cases copyright and header must remain intact.#
##############################################################################
# Define Variables

$log_file = "/home/ftp/pub/voxroom/public_html/logs/vsr.log";

$web = "1";

$min_refs = "50";
$min_remote = "50";
$min_agent = "50";
$min_browser = "50";
$min_platform = "50";

##############################################################################
# Select Options

$expand_agent = 0;      # 0 = NO; 1 = YES
$show_percent = 1;      # 0 = NO; 1 = YES

$title = "The VOX Showroom";
$title_url = "http://www.voxshowroom.com/";

# Done
##############################################################################
%weekday=("0","Sunday","1","Monday","2","Tuesday","3","Wednesday","4","Thursday",
"5","Friday","6","Saturday");

%months=("01","January","02","Feburary","03","March","04","April","05","May","06",
"June","07","July","08","August","09","September","10","October","11","November",
"12","December");

($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
if ($sec < 10)  { $sec = "0$sec";   }
if ($min < 10)  { $min = "0$min";   }
if ($hour < 10) { $hour = "0$hour"; }
if ($mday < 10) { $mday = "0$mday"; }
if ($mon < 10)  { $monc = "0$mon";  }

if ($web == 1) {
   print "Content-type: text/html\n\n";
}


$date_now = sprintf("%02d:%02d:%02d %02d/%02d/%02d",$hour,$min,$sec,
             $mon+1,$mday,$year);
$mon++;
#$date_now = "$hour\:$min\:$sec $mon+1/$mday/$year";

open(DB,"$log_file") || die "Cannot Open Log File $log_file: $!";
@lines = <DB>;
close(DB);

$accesses = @lines;

if ($lines[1] =~ /\[(.*)\] (.*) - (.*) - (.*)/) {
   $first_date = $1;
}
else {
   $first_date = 0;
}

if ($lines[($accesses - 1)] =~ /\[(.*)\] (.*) - (.*) - (.*)/) {
   $last_date = $1;
}
else {
   $last_date = 0;
}

foreach $line (@lines) {
   if ($line =~ /\[(.*)\] (.*) - (.*) - ((.*) \((.*)\))/) {
      $date = $1;
      ($clock,$time,$day) = split(/ /,$date);
      ($hour,$minute,$second) = split(/:/,$clock);
      $referer = $2;
      $referer =~ s/\%24/\$/g;
      $referer =~ s/\%7E/~/g;
      $remote_host = $3;
      $user_agent = $4;
      $browser = $5;
      $platform = $6;

      if ($time eq 'PM') {
         $hour += 12;
      }

      if ($day ne '' && $day ne ' ') {
         push(@DAYS, $day);
      }
      if ($hour ne '' && $hour ne ' ') {
         push(@HOURS, $hour);
            }
      if ($mon ne '' && $mon ne ' ') {
         push(@MON, $mon);
      }
      if ($referer ne 'No Referer' && $referer ne ' ' && $referer ne '') {
         push(@REFERER, $referer);
      }
      if ($remote_host ne 'No Remote_Host' && $remote_host ne ' ' &&
$remote_host ne '') {
         push(@REMOTE_HOST, $remote_host);
      }
      if ($user_agent ne 'No User_Agent' && $user_agent ne ' ' &&
$user_agent ne '') {
         push(@USER_AGENT, $user_agent);
      }
      if ($browser ne 'No Browser' && $browser ne ' ' && $browser ne '') {
         push(@BROWSER, $browser);
      }
      if ($platform ne 'No Platform' && $platform ne ' ' && $platform ne '') {
         push(@PLATFORM, $platform);
      }
   }
}

foreach (@REFERER) {
   $refs{($_)[0]}++;
   $i++;
}

foreach (@REMOTE_HOST) {
   $remote{($_)[0]}++;
   $j++;
}

foreach (@USER_AGENT) {
   if ($expand_agent == 1) {
      $agent{($_)[0]}++;
   }
   else {
    $agent{(split('\.',$_))[0]}++;
   }
   $k++;
}

foreach (@BROWSER) {
   $browser{($_)[0]}++;
   $l++;
}

foreach (@PLATFORM) {
   $platform{(split('\;',$_))[0]}++;
   $m++;
}

foreach (@DAYS) {
   $day{($_)[0]}++;
}

foreach (@MON) {
   $mon{($_)[0]}++;
}

foreach (@HOURS) {
   $hour{($_)[0]}++;
}

&html_header;

sub html_header {
   print "<html><head><title>Access Stats for $title</title></head>\n";
   print "<body bgcolor=\"#000000\" text=\"#FFFFFF\" link=\"#FF0000\" 
vlink=\"#00FF00\"><BASEFONT SIZE=3>";
   print "<br><br><center><IMG
SRC=\"http://www.voxshowroom.com/ct/des/nuvsr.gif\" \n";
   print "ALT=\"The VOX Showroom!\" HEIGHT=116 WIDTH=416><br><br><br>\n";
   print "<p><strong><FONT COLOR=\"D7CC00\" size=5>Access Stats for
$title</font></strong><p>\n";
   print "<TABLE BORDER=0 CELLSPACING=5 CELLPADDING=5 WIDTH=430><TR><TD
VALIGN=MIDDLE ALIGN=LEFT>\n";
   print "Below are the access stats for $title.<p>\n";
   print "A total of $accesses were reviewed for this logging, which
occurred at: $date_now</TD></TR></TABLE>\n";
   if ($first_date != 0 && $last_date != 0) {
      print "These statistics reflect accesses from: <i>$first_date</i> to
<i>$last_date</i></TD></TR></TABLE>\n";
   }
   print "<hr width=485>\n";
   print "<font size=-1>[ <a href=\"\#refs\">Referring Web Pages</a> ] [ <a
href=\"\#remote_host\">Remote Hosts</a> ] [ <a
href=\"\#browsers\">Browsers</a> ] [ <a href=\"\#platform\">Platform</a> ]
[ <a href=\"\#days\">Hits by Day</a> ] [ <a href=\"\#month\">Hits By
Month</a> ] [ <a href=\"\#hours\">Hits by
Hour</a> ]</font>\n";
   print "<hr width=485><p>\n";

   &html_referer;
   &html_remote_host;
#   &html_user_agent;
   &html_browser;
   &html_platform;
   &days;
   &mon;
   &hours;
   &html_trailer;
}

sub html_referer {
   print "<strong><FONT COLOR=\"D7CC00\" size=4><a name=\"refs\">Referring
Web Pages</a></font></strong>\n";
   print "<p><b>Referring URLs Searched:</b> <i><u>$i</u></i><br>\n";
   print "<b>Minimum References Required to Make List:</b> $min_refs</u></i>\n";

   print "<blockquote><table border=1 cellpadding=2>\n";
   if ($show_percent == 1) {
      print "<tr><th>Number </th><th>Percent </th><th>Referring Web
Sites</th></tr>\n";
   }
   else {
      print "<tr><th>Number </th><th>Referring Web Sites<br></th></tr>\n";
   }
   foreach (sort { $refs{$b} <=> $refs{$a} } keys %refs) {
      if ($refs{$_} >= $min_refs) {
         print "<tr>\n";
         $total_refs += $refs{$_};
         if ($show_percent == 1) {
            $percent_refs = (int(10000 * ($refs{$_} / $i)) / 100);
            $total_percent_refs += $percent_refs;
            print "<th>$refs{$_} </th><th>$percent_refs\% </th><td
valign=middle><a href=\"$_\">$_</a><br></td>\n";
#            printf( "<th>$refs{$_} </th><th>%3.2f\% </th><td
#valign=middle><a href=\"$_\">$_</a><br></td>\n",$percent_refs);
         }
         else {
            print "<th>$refs{$_} </th><td><a href=\"$_\">$_</a><br></td>\n";
         }
         print "</tr>\n";
      }
   }
   if ($show_percent == 1) {
      print "<tr><th>$total_refs </th><th>$total_percent_refs\%
</th><th>Totals For URLS Shown</th></tr>\n";
#      printf( "<tr><th>$total_refs </th><th>%3.2f\% </th><th>Totals For
#URLS Shown</th></tr>\n",$total_percent_refs);
   }
   else {
      print "<tr><th>$total_refs </th><th>Totals For URLS Shown</th></tr>\n";
   }
   print "</table></blockquote><p>\n";
}

sub html_remote_host {
   print "<strong><FONT COLOR=\"D7CC00\" size=4><a
name=\"remote_host\">Remote Hosts</a></font></strong>\n";
   print "<p><b>Remote Hosts Searched:</b> <u><i>$j</i></u><br>\n";
   print "<b>Minimum Hits Required to Make List:</b>
<i><u>$min_remote</u></i>\n";
   print "<blockquote><table border=1 cellpadding=2>\n";
   if ($show_percent == 1) {
      print "<tr><th>Number of Hits </th><th>Percent </th><th>Remote
Hosts<br></th></tr>\n";
   }
   else {
      print "<tr><th>Number of Hits </th><th>Remote Hosts<br></th></tr>\n";
   }
   foreach (sort { $remote{$b} <=> $remote{$a} } keys %remote) {
      if ($remote{$_} >= $min_remote) {
         print "<tr>\n";
         if ($show_percent == 1) {
            $percent_remote = (int(10000 * ($remote{$_} / $j)) / 100);
            print "<th>$remote{$_} </th><th>$percent_remote\%
</th><td>$_<br></td>\n";
#            printf( "<th>$remote{$_} </th><th>%3.2f\%
#</th><td>$_<br></td>\n",$percent_remote);
         }
         else {
            print "<th>$remote{$_} </th><td>$_<br></td>\n";
         }
         print "</tr>\n";
      }
   }
   print "</table></blockquote><p>\n";
}

sub html_user_agent {
   print "<a name=\"browsers\">\n";
   print "<strong><FONT COLOR=\"D7CC00\" size=4>WWW
Browsers</font></strong></a>\n";
   print "<p><b>Agents Searched:</b> <u><i>$k</i></u><br>\n";
   print "<b>Minimum Hits Required to Make List:</b>
<u><i>$min_agent</i></u>\n";
   print "<blockquote><table border=1 cellpadding=2>\n";
   if ($show_percent == 1) {
      print "<tr><th>Number of Hits </th><th>Percent
</th><th>Browser<br></th></tr>\n";
   }
   else {
      print "<tr><th>Number of Hits </th><th>Browser<br></th></tr>\n";
   }

   foreach (sort { $agent{$b} <=> $agent{$a} } keys %agent) {
      if ($agent{$_} >= $min_agent) {
         print "<tr>\n";
         if ($show_percent == 1) {
            $percent_agent = (int(10000 * ($agent{$_} / $k)) / 100);
           printf( "<th>$agent{$_} </th><th>%3.2f\%
</th><td>$_<br></td>\n",$percent_agent);
         }
         else {
            print "<th>$agent{$_} </th><td>$_<br></td>\n";
         }
         print "</tr>\n";
      }
   }
   print "</table></blockquote>\n";
}

sub html_browser {
   print "<a name=\"browsers\">\n";
   print "<strong><FONT COLOR=\"D7CC00\" size=4>WWW
Browsers</font></strong></a>\n";
   print "<p><b>Browsers Searched:</b> <u><i>$l</i></u><br>\n";
   print "<b>Minimum Hits Required to Make List:</b>
<u><i>$min_browser</i></u>\n";
   print "<blockquote><table border=1 cellpadding=2>\n";
   if ($show_percent == 1) {
      print "<tr><th>Number of Hits </th><th>Percent
</th><th>Browser<br></th></tr>\n";
   }
   else {
      print "<tr><th>Number of Hits </th><th>Browser<br></th></tr>\n";
   }

   foreach (sort { $browser{$b} <=> $browser{$a} } keys %browser) {
      if ($browser{$_} >= $min_browser) {
         print "<tr>\n";
         if ($show_percent == 1) {
            $percent_agent = (int(10000 * ($browser{$_} / $k)) / 100);
           printf( "<th>$browser{$_} </th><th>%3.2f\%
</th><td>$_<br></td>\n",$percent_agent);
         }
         else {
            print "<th>$browser{$_} </th><td>$_<br></td>\n";
         }
         print "</tr>\n";
      }
   }
   print "</table></blockquote>\n";
}

sub html_platform {
   print "<a name=\"platform\">\n";   
   print "<strong><FONT COLOR=\"D7CC00\" size=4>Computer
Platform</font></strong></a>\n";
   print "<p><b>Platforms Searched:</b> <u><i>$m</i></u><br>\n";
   print "<b>Minimum Hits Required to Make List:</b>
<u><i>$min_platform</i></u>\n";
   print "<blockquote><table border=1 cellpadding=2>\n";
   if ($show_percent == 1) {
      print "<tr><th>Number of Hits </th><th>Percent
</th><th>Platform<br></th></tr>\n";
   }
   else {
      print "<tr><th>Number of Hits </th><th>Platform<br></th></tr>\n";
   }

   foreach (sort { $platform{$b} <=> $platform{$a} } keys %platform) {
      if ($platform{$_} >= $min_platform) {
         print "<tr>\n";
         if ($show_percent == 1) {
            $percent_agent = (int(10000 * ($platform{$_} / $k)) / 100);
           printf( "<th>$platform{$_} </th><th>%3.2f\%
</th><td>$_<br></td>\n",$percent_agent);
         }
         else {
            print "<th>$platform{$_} </th><td>$_<br></td>\n";
         }
         print "</tr>\n";
      }
   }
   print "</table></blockquote>\n";
}

sub hours {
   print "<a name=\"hours\">\n";
   print "<strong><FONT COLOR=\"D7CC00\" size=4>Hits By
Hour</font></strong></a>\n";
   print "<blockquote><table border=1 cellpadding=2>\n";
   print "<tr><th>Hour </th><td>Number of Hits<br></td></tr>\n";
   foreach (sort keys %hour) {
      print "<tr>\n";
      print "<th>$_ </th><td>$hour{$_}<br></td>\n";
      print "</tr>\n";
   }
   print "</table></blockquote>\n";
}

sub mon {
    print "<a name=\"month\">\n";
    print "<strong><FONT COLOR=\"D7CC00\" size=4>Hits by
Month</font></strong></a>\n";
    print "<blockquote><table border=1 cellpadding=2>\n";
    print "<tr><th>Month </th><td>Number of Hits<br></td></tr>\n";
    foreach (sort keys %months) {
       print "<tr>\n";
       print "<th>$months{$_}</th><td>$mon{$_}<br></td></tr>\n"
    }
    print "</table></blockquote>\n";
}

sub days {
   print "<a name=\"days\">\n";
   print "<strong><FONT COLOR=\"D7CC00\" size=4>Hits By
Day</font></strong></a>\n";
   print "<blockquote><table border=1 cellpadding=2>\n";
   print "<tr><th>Day </th><td>Number of Hits<br></td></tr>\n";
   foreach (sort keys %day) {
      print "<tr>\n";
      print "<th>$weekday{$_}</th><td>$day{$_}<br></td>\n";
#    print "<th>$_ </th><td>$day{$_}<br></td>\n";
      print "</tr>\n";
   }
   print "</table></blockquote>\n";
}

sub html_trailer {
   print "<hr width=485>\n";
   print "<font size=-1>[ <a href=\"\#refs\">Referring Web Pages</a> ] [ <a
href=\"\#remote_host\">Remote Hosts</a> ] [ <a
href=\"\#browsers\">Browsers</a> ] [ <a href=\"\#platform\">Platform</a> ]
[ <a href=\"\#days\">Hits by Day</a> ] [ <a href=\"\#month\">Hits By
Month</a> ] [
<a href=\"\#hours\">Hits by Hour</a> ]\n";
   print "<hr width=485>\n";
   print "<br><br><br>\n";
   print "<IMG WIDTH=145 HEIGHT=35
SRC=\"http://www.voxshowroom.com/ct/des/redvox.gif\" ALT=\"Vox!\">\n";
   print "<br><br><br>\n";      
   print "<font size=1>URL:  http://www.voxshowroom.com/cgi/vsr_log.cgi\n";
   print "<BR>Contact The VOX Showroom at \n";
   print "<A HREF=\"email.html\">voxroom\@\microweb.com</A><br>\n";
   print "&copy; 1997 Barking Dog Productions</A>. All rights reserved.<BR>\n"; 
   print "</center></font></body>\n</html>\n";  
}


------------------------------

Date: 12 Mar 1997 18:34:07 GMT
From: earl@shadowfax.rchland.ibm.com (Joel Earl)
Subject: Re: Chopping lines?
Message-Id: <EARL.97Mar12123407@shadowfax.rchland.ibm.com>

In article <33203E41.4378@att.com> Joe Moore <joemoore@att.com> writes:

> Ted Timmons wrote:
> > 
> > I'd like to chop long lines so that they are around 70 characters. I
> > don't need to worry about long/short line pairs (from having, say,
> > 90-character lines) because of the application.
> > 
> > Right now, I'm using something like this:
> > 
> > $data equals some long string
> > $data1 = substr ($data,0,70);
> > $data = substr ($data, 70);
> > print out $data1, start over (more or less)
> > 
> > The problem is it doesn't chop on word breaks. I've tried using a regexp
> > with s/.*\W(\w+)/$1/; and several other combinations, but it doesn't
> > like non-alphanumerics, like (, #, and more. Does anyone have any
> > suggestions?
>

 ... Joe's code deleted ...

For a modular solution, Text::Wrap is part of the standard distribution:

  use Text::Wrap qw(wrap $columns);
  $columns = 70;
  $short_@lines = wrap('','',$longline);
-- 

   Joel Earl, earl@vnet.ibm.com
   Logic Analysis and Optimization
   IBM Rochester, Minnesota
   (507) 253-2304


------------------------------

Date: 12 Mar 1997 10:06:02 -0800
From: asialive@best.com (Sherman Hsieh)
Subject: Elegant way to strip spaces off the ^ and $ of a variable containing a sentence.
Message-Id: <5g6raa$5gl@shellx.best.com>

Hi all,
	I couldn't come up with an elegant way to strip off spaces
(newline, tab or whatever) of a string. Does anyone have a good solution
to this.

Example:

$variable = "	 jklsd jslkjsd   ";

I want to strip off all the spaces before and after the string above so
the resulting string should look like:

$variable = "jklsd jslkjsd";

Thanks in advance for any advice or help on this.

	-Sherman



------------------------------

Date: Wed, 12 Mar 1997 09:27:22 -0600
From: Greg Sinclair <gjsincla@tddcae99.fnts.com>
Subject: exec & nohup
Message-Id: <3326CB5A.2CAA@tddcae99.fnts.com>

hello,

i have a simple question concerning the exec command.  does exec
work like 'nohup' in that the executed process/program will 
continue running even if the terminal or session is closed? i am
seeing this behaviour, but have not seen any documentation describing
this type of a situation.

Thanks for your help.

Greg Sinclair

-- 
------------------------------------------------------------------------
Greg Sinclair                                 g_sinclair@fujitsu-fnc.com
Sr. Hardware Designer                              voice : (972)479-3846
Fujitsu Network Communications                     fax   : (972)479-2666
------------------------------------------------------------------------


------------------------------

Date: Wed, 12 Mar 1997 11:01:48 -0600
From: Daneshjoo <eermmb@engunx.unl.edu>
Subject: Help with "waitfor.pl"
Message-Id: <Pine.OSF.3.91.970312105506.20301B-100000@engunx.unl.edu>

Hi :

	I'm trying to find a way to use the multiple user option for the 
program "waitfor.pl", which is a program that fingers specified domains, 
and if the user we want is logged on, will tell us.  If any one out there 
has been able to modify the program to do more than one user at the same 
time, could you please email me and let me know what I shall do.  TIA


				Daneshjoo 


			  eermmb@engvms.unl.edu			



------------------------------

Date: Wed, 12 Mar 1997 09:16:59 -0800
From: Ronak Bhatt <rbhatt@netscape.com>
Subject: How do I get all more than 2 hours old files
Message-Id: <3326E50B.1CB0@netscape.com>

Hi,

How would I get the filenames, that were created before two hours ( when
the script is run).

Thanks, Ronak.


------------------------------

Date: Wed, 12 Mar 1997 18:15:20 +0100
From: Eike Grote <eike.grote@theo.phy.uni-bayreuth.de>
Subject: Re: MacPerl5
Message-Id: <3326E4A8.2781@theo.phy.uni-bayreuth.de>

Hi,

Juergen Seeger wrote:
> 
> Is anyone here who is using MacPerl?

Yes, I do ...   ;-)


Eike

=====================================================================
 Eike Grote, Theoretical Physics IV, University of Bayreuth, Germany
            email : eike.grote@theo.phy.uni-bayreuth.de
           URL : http://www.phy.uni-bayreuth.de/~btpa25/ 
=====================================================================


------------------------------

Date: Wed, 12 Mar 1997 17:19:45 GMT
From: lars.oberg@hasselblad.se (Lars Oberg)
Subject: Perl 5.003 on Solaris 2.4
Message-Id: <3326e376.31784362@nntpserver.swip.net>

Hi,

I don't know anything about Perl, but I need to run SATAN 1.1.1, and
it requires Perl v5.0 or above. I have downloaded
"perl-5_003-libwww-perl-5_03" from smc.vnet.net/solaris_2.5.html (a
precompiled version that should work on Solaris).

When I try to start Satan, I get: 'Unsupported socket function
"getprotobyname" called at perl/html.pl line 130'. If i start perl and
enter  getprotobyname('tcp'), it gives me the same message.
Unfortunately I'm not very familiar with the Unix programming
environment.

Does anyone have any advice? I would be very grateful.

Thanks in advance!

Lars Oberg (lars.oberg@hasselblad.se)


------------------------------

Date: 12 Mar 1997 13:35:39 -0500
From: Stefan Monnier <monnier@cs.yale.edu>
Subject: Re: Perl FAQ part 8 of 0..9: System Interaction [Periodic Posting]
Message-Id: <5lvi6xargk.fsf@tequila.systemsz.cs.yale.edu>

Tom Christiansen <tchrist@mox.perl.com> writes:
> =head2 How do I keep my own module/library directory?
> 
> When you build modules, use the PREFIX option when generating
> Makefiles:
> 
>     perl Makefile.PL PREFIX=/u/mydir/perl
> 
> then either set the PERL5LIB environment variable before you run
> scripts that use the modules/libraries (see L<perlrun>) or say
> 
>     use lib '/u/mydir/perl';
> 
> See Perl's L<lib> for more information.

Reminds me of a question:
where should dynamically linked modules be put ?
I created a /usr/local/lib/perl5 dir where I keep my perl modules, but if I set
my PERL5LIB to /usr/local/lib/perl5, only /usr/local/lib/perl5 and
/usr/local/lib/perl5/auto are searched for .so files, whereas I would much
prefer to put the .so files at their "natural" place (in my case
/usr/local/lib/perl5/i386-linux/5.003) but this requires me to add
/usr/local/lib/perl5/i386-linux/5.003 to my PERL5LIB path, which seems ugly to
me. What is the "normal" solution ?


        Stefan


------------------------------

Date: 12 Mar 97 16:21:12 GMT
From: dianne  cooper <cooper15@hsonline.net>
Subject: Perl Interpretors
Message-Id: <3326d7f8.0@news.hsonline.net>

Hi,
  I'm setting up my own server and I've been looking all over
for a perl interpretor for Windows95. The only ones I find are
for UNIX. Do I need to pay or order one? Or are they for 
download? I'd be glad if you could help me.

Cameron Cooper
Cooper15@hsnline.net


------------------------------

Date: 12 Mar 1997 18:10:33 GMT
From: Alain.Deckers@man.ac.uk (A. Deckers)
Subject: Re: Perl Interpretors
Message-Id: <slrn5idscq.7er.Alain.Deckers@nessie.mcc.ac.uk>

In <3326d7f8.0@news.hsonline.net>,
	dianne  cooper <cooper15@hsonline.net> wrote:
>Hi,
>  I'm setting up my own server and I've been looking all over
>for a perl interpretor for Windows95. The only ones I find are
>for UNIX. Do I need to pay or order one? Or are they for 
>download? I'd be glad if you could help me.

Perhaps the Perl FAQ, posted to comp.lang.perl.announce, hasn't
propagated to your site yet? If so you'll find it at the URL quoted in my
 .sig. It'll tell you all about obtaining alien ports of Perl.

HTH,
-- 
Alain.Deckers@man.ac.uk          <URL:http://www.man.ac.uk/%7Embzalgd/>
Perl information: <URL:http://www.perl.com/perl/>
        Perl FAQ: <URL:http://www.perl.com/perl/faq/>
   Perl software: <URL:http://www.perl.com/CPAN/>


------------------------------

Date: Wed, 12 Mar 1997 12:03:08 -0500
From: "Mark T. Kennedy" <mtk@ny.ubs.com>
Subject: Re: Signal catching with alarm
Message-Id: <3326E1CC.1AF8@ny.ubs.com>

rich, unless you're just programming for fun, 
this kind of stuff is already well-upported by libwww.
it has a 'timeout' method which sets the you-know-what and 
a 'use-eval' method which lets you trap the timeout when you
wrap the 'request' method with an eval.

/mark kennedy
vice president
union bank of switzerland

Rich Schramm wrote:
> 
> Hi,
> 
> I am writing a script that measures the elapsed time of retrieving a given
> URL. The condition I am actually testing for will be when a URL does not
> come back in a reasonable period of time.  Therefore, I need to make the
> program work so that after a given number of seconds, the "get" will abort
> and return an exit code to indicate the problem.
> 
> Enter the alarm function. I am running alarm (twice actually to print the
> return code to verify that the alarm is actually being set), but after the
> given period of time, nothing happens.  It appears that my signal catching
> code is not functioning.  I have used signal catching before with the CHLD
> sig, during fork operations with expected results.  Similar code used for
> the ALRM sig seems to have no effect.
> 
> The chunks that don't seem to work are:
> 
> $SIG{'ALRM'} = 'exitone';
> sub exitone {
> # Took longer than maxsecs to return,
> # so exit 1
> print "Times Up!\n";
> exit(1);
> }
> 
> alarm(5);
> 
> If anyone can tell me what is up with this, I would appreciate it.  The
> script that is failing (the alarm part anyway) is below.
> 
> Thanks,
> 
> Rich
> 
> #!/usr/local/bin/perl
> #
> ##############################################################
> # Connects to the URL, downloads the src and return number of
> # seconds it took to get the URL.
> ##############################################################
> $url = $ARGV[0];
> $maxsec = $ARGV[1];
> 
> $SIG{'ALRM'} = 'exitone';
> # If you receive the ALRM signal, go to the
> # exitone subroutine
> 
> $SIG{'CHLD'} = 'do_wait';
> # If you receive the child signal, go to the
> # do_wait subroutine
> 
> if ($url eq '' || $maxsec == '') {
>  die "Usage: $0 [http|ftp]://servername/url maxseconds\n";
> }
> 
> $pid = fork;
> 
> if ($pid == 0) {
> 
>   # this is the child process
> 
>   $start_time=time;
>   $test=alarm 5;
>   print "$test\n";
>   $test=alarm 5;
>   print "$test\n";
>   # to make sure signal is really started.
> 
>   # Create a user agent object
>   use LWP::UserAgent;
>   $ua = new LWP::UserAgent;
>   $ua->agent("TimeChecker/0.9");
> 
>   # Create request
>   my $req = new HTTP::Request GET => "$url";
> 
>   # Pass request to the user agent and get a response back
>   my $res = $ua->request($req);
> 
>   # Check the outcome of the response
>   if ($res->is_success) {
>   $srvresp = $res->content;
>   } else {
>   exit(2);
>   }
> 
>   sleep 10; # for testing signal
>   $stop_time=time;
>   #print "Stop: $stop_time\n";
>   $elapsed=$stop_time - $start_time;
> 
>   # Print the elapsed time;
>   print "$elapsed\n";
>   exit(0);
> }
> 
> $SIG{'CHLD'} = 'DEFAULT';
> while ( $kids != -1 ) {
>   $kids=wait;
> }
> 
> ######################
> # Subroutines
> ######################
> 
> sub exitone {
> # Took longer than maxsecs to return,
> # so exit 1
> print "Times Up!\n";
> exit(1);
> }
> 
> sub do_wait {
>  $pid=wait;
> }


------------------------------

Date: 12 Mar 1997 13:24:50 GMT
From: dxe@cassidy.sbi.com (Dan Ellsweig (Enterprise Management))
Subject: year 2000 question
Message-Id: <5g6ar2$g7s@tensapp.sbi.com>


Greetings

I am in the process of insuring year 2000 compliance for all of
my PERL code. I have a question regarding the 'localtime()' library
function.

Does anyone know of a version of PERL which will support
4 character year as returned by localtime()?? Currently
the localtime function calculates the correct year then it
subtracts 100 from the year before returning the year value
in the localtime array. The result is a 2 character year (99 for 1999 or
00 for 2000). 

Dan


-- 
******************************************************************************
Dan Ellsweig    **   Salomon Inc.               **  dellsweig@sbi.com
                **   Route 3   Rutherford, N.J. **  (201) 896-6162
                **   Enterprise Management      **  (800) 800-7759 PIN 221370
******************************************************************************


------------------------------

Date: 12 Mar 1997 19:30:12 +0200
From: Jarkko Hietaniemi <jhi@alpha.hut.fi>
Subject: Re: year 2000 question
Message-Id: <oee209lnhln.fsf@alpha.hut.fi>


> Does anyone know of a version of PERL which will support
> 4 character year as returned by localtime()?? Currently
> the localtime function calculates the correct year then it
> subtracts 100 from the year before returning the year value
> in the localtime array. The result is a 2 character year (99 for 1999 or
> 00 for 2000). 

NO NO NO NO NO NO!

Please read the localtime() documentation. In a UNIX system: "man localtime".

There are NO _two_ "characters" returned, it is a _number_.

It is not "year minus 100", it is year - 1900. Therefore 2000 -> 100.

-- 
$jhi++;
# Jarkko Hietaniemi <URL:http://www.iki.fi/~jhi/> <URL:mailto:jhi@iki.fi>
# Lost interest?  It's so bad I've lost apathy.
# Not speaking for any past, present, or future employers.


------------------------------

Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 8 Mar 97)
Message-Id: <null>


Administrivia:

The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc.  For subscription or unsubscription requests, send
the single line:

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.

The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.

The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.

For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V8 Issue 103
*************************************

home help back first fref pref prev next nref lref last post