[10517] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4109 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Oct 30 00:06:52 1998

Date: Thu, 29 Oct 98 21:00:18 -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           Thu, 29 Oct 1998     Volume: 8 Number: 4109

Today's topics:
        A perl Question <gss2@roogna.eng.wayne.edu>
        Almost Newbie Question. Passing %x and @x to a sub in a <millman@interport.net>
    Re: Almost Newbie Question. Passing %x and @x to a sub  <mpersico@erols.com>
    Re: Almost Newbie Question. Passing %x and @x to a sub  <r28629@email.sps.mot.com>
    Re: ANNOUNCE:  New Arrival <uri@sysarch.com>
    Re: ANNOUNCE:  New Arrival (Tad McClellan)
    Re: Anything like /bin/bash -x for perl? (Tad McClellan)
    Re: Checking Input for Exactly 2 numbers (Tad McClellan)
    Re: Easy Question: Rounding Numbers (Larry Rosler)
    Re: Easy Question: Rounding Numbers (Tad McClellan)
    Re: Easy Question: Rounding Numbers <r28629@email.sps.mot.com>
    Re: Need help appending a string to a hash <r28629@email.sps.mot.com>
    Re: Not to start a language war but.. <uri@sysarch.com>
    Re: Not to start a language war but.. <zenin@bawdycaste.org>
    Re: Not to start a language war but.. (Ilya Zakharevich)
    Re: Not to start a language war but.. (Larry Rosler)
    Re: Perl & Y2K - booby trap code (Craig Berry)
    Re: Perl & Y2K - booby trap code (Craig Berry)
    Re: Perl & Y2K - booby trap code (Larry Rosler)
        remotely hosted access log (Alan Jiang)
    Re: remotely hosted access log (Ethan H. Poole)
        Very Large DBM file: Finding Number of keys (Bob Stewart)
    Re: Very Large DBM file: Finding Number of keys <rra@stanford.edu>
    Re: Very Large DBM file: Finding Number of keys (Larry Rosler)
    Re: Very Large DBM file: Finding Number of keys <rra@stanford.edu>
    Re: Yet another list of lists question <r28629@email.sps.mot.com>
        Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)

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

Date: Thu, 29 Oct 1998 21:44:22 -0500
From: shienh gurpreet <gss2@roogna.eng.wayne.edu>
Subject: A perl Question
Message-Id: <36392805.7AD03480@roogna.eng.wayne.edu>

Hello Experts!!
Here's a script that I wrote (don't laugh at its simplicity as its my
second perl script). I ask the user to give their password and if it
matches against the their password in the data file, they get to see
their info (their grades etc.)Here's a sample of the data file:The first
two fields are used as the login and password to be matched. If both of
them match, they get to see their lab, midterm grades.

8558:fine:Augustus:labs=85,88.96,58.7,58.88,89.5,76.7,87.73,80:midterm=59:final=98

7789:kick:Darwin:labs=89,66.79.6,88.99,78,99,77,88,100:midterm=55:final=95

Here's the script I wrote:

The problem that I'm having is that when I enter the password on my
webpage,it says "Document Contains No Data". Also I don't know how to
prompt the user if none of the passwords is matched (something like
sorry, wrong password.)

#!usr/local/bin/perl

$a=<stdin>;
($f_soc,$f_pass)=split(/&+/,$a);
$f_soc=~s/\w+=//g;
$f_pass=~s/\w+=//g;
chop($f_pass);
open (H,"hw4.dat");
@h=<H>;
$lab_gross=shift(@h);
$h=@h;
foreach $h(@h)
{
($soc,$pass,$name,$labs,$midterm,$final)=split(/:+/,$h);
$labs=~s/\w+=//g;
$midterm=~s/\w+=//g;
$final=~s/\w+=//g;
@labs=split(/,+/,$labs);
$lab_total=0;
for ($i=0; $i<=7; $i++)
{
$lab_total+=$labs[$i];
}
if ($f_soc eq $soc && $f_pass eq $pass)
{
print "$soc\n";
$overall=((($lab_total/$lab_gross)*40)+($midterm*0.3)+($final*0.3));
print "content-type:text/html\n\n";
print  "<html><head><title>Homework # 4 Results</title></head> <body
bgcolor=white>\n";
print "<center><h2>Gurpreet's Homework # 4 Results</h2><hr noshade
width=70%>\n";
print "Welcome, $name. Below are your grades for the course.\n";
print "<table border=2 align=center><tr><td>Lab Grades<td>Midterm
Exam<td>Final Exam<td>Overall Grade</tr>\n";
print "<tr><td>@labs<td>$midterm<td>$final<td>\n";
printf "%4.2f\n",$overall;
print "</table></html>\n";
}
}
close (H);

Please guide me..
sheeku
shienh_wsu@hotmail.com



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

Date: Fri, 30 Oct 1998 02:44:32 GMT
From: Phillip Millman <millman@interport.net>
Subject: Almost Newbie Question. Passing %x and @x to a sub in a module.
Message-Id: <363927FB.B207253E@interport.net>

I'm trying without success to do this

$rc = &myFunc($x,\@y,\%z);

sub myFunc {
# How do I access those variables??

}

I'm sure its somewhere in the documentation but I haven't been able to
figure it out.

Thanks
--
Phillip Millman            millman@interport.net

There is a point at which comedy turns into
tragedy. That point has arrived.  -Plato




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

Date: Thu, 29 Oct 1998 22:53:59 -0500
From: "Matthew O. Persico" <mpersico@erols.com>
Subject: Re: Almost Newbie Question. Passing %x and @x to a sub in a module.
Message-Id: <71bd89$f1b$1@autumn.news.rcn.net>

Arguments are passed in the magic @_ array.

sub myFunc {
my($x, $refToArrayY, $refToHashZ) = @_;

print "arg1 = $x\n";
print "arg2 = (\n";
foreach (@{$refToArrayY}) {
    print "$_\n";
}
print ")\n"
print "arg3= (\n";
foreach (keys %{$refToHashZ}) {
    print "$_ => $refToHashZ->{$_}\n";
}
print "_\n";

Read the docs for  perlsub

Phillip Millman wrote in message <363927FB.B207253E@interport.net>...
>I'm trying without success to do this
>
>$rc = &myFunc($x,\@y,\%z);
>
>sub myFunc {
># How do I access those variables??
>
>}
>
>I'm sure its somewhere in the documentation but I haven't been able to
>figure it out.
>
>Thanks
>--
>Phillip Millman            millman@interport.net
>
>There is a point at which comedy turns into
>tragedy. That point has arrived.  -Plato
>
>




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

Date: Thu, 29 Oct 1998 21:31:42 -0500
From: Tk Soh <r28629@email.sps.mot.com>
To: Phillip Millman <millman@interport.net>
Subject: Re: Almost Newbie Question. Passing %x and @x to a sub in a module.
Message-Id: <36392509.F55B7309@email.sps.mot.com>

[posted and copy emailed]

Phillip Millman wrote:
> 
> I'm trying without success to do this
> 
> $rc = &myFunc($x,\@y,\%z);
> 
> sub myFunc {
> # How do I access those variables??

       $arrayref->[$index] = "VALUE";   # Array element
       $hashref->{"KEY"} = "VALUE";     # Hash element
 
> }
> 
> I'm sure its somewhere in the documentation but I haven't been able to
> figure it out.

Go look it up:
   perldoc perlref

-tk


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

Date: 29 Oct 1998 21:19:39 -0500
From: Uri Guttman <uri@sysarch.com>
Subject: Re: ANNOUNCE:  New Arrival
Message-Id: <x7emrqeqpw.fsf@sysarch.com>

>>>>> "TS" == Tk Soh <r28629@email.sps.mot.com> writes:

  TS> [post and copy emailed]
  TS> Daniel Grisinger wrote:
  >> 
  >> Hannah Elizabeth Grisinger entered the world at
  >> 5:45 am, 29 October 1998.  She weighed 6 lbs, 15 ozs.
  >> and was 19 inches long.
  >> 
  >> Mother and daughter are recuperating in the hospital,
  >> father is delirious with joy :-).

  TS> I like Hannah Elizabeth Pe(a)rl Grisinger better ? ;-)

shouldn't that be /Pea?rl/ ?

:-)

uri

-- 
Uri Guttman  -----------------  SYStems ARCHitecture and Software Engineering
Perl Hacker for Hire  ----------------------  Perl, Internet, UNIX Consulting
uri@sysarch.com  ------------------------------------  http://www.sysarch.com
The Best Search Engine on the Net -------------  http://www.northernlight.com


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

Date: Thu, 29 Oct 1998 21:21:35 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: ANNOUNCE:  New Arrival
Message-Id: <vbbb17.4hr.ln@flash.net>

Daniel Grisinger (dgris@rand.dimensional.com) wrote:
: Hannah Elizabeth Grisinger entered the world at
: 5:45 am, 29 October 1998.  She weighed 6 lbs, 15 ozs.
: and was 19 inches long.  

: Mother and daughter are recuperating in the hospital, 
: father is delirious with joy :-).


   Sorry to see you leaving c.l.p.misc.

   I've enjoyed reading your postings.


   The Time Sink has been delivered  ;-)


   Congratulations!


--
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: Thu, 29 Oct 1998 21:31:51 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Anything like /bin/bash -x for perl?
Message-Id: <7vbb17.fnr.ln@flash.net>

tbrannon (brannon@quake.usc.edu) wrote:

: I would like for each line of my Perl program to to printed to stdout
: just prior to execution.

: I would also like to have the values of my variables printed as their
: values change.

: Please advise on the methods to achieve this.


   perldoc perldebug


--
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: Thu, 29 Oct 1998 21:08:07 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Checking Input for Exactly 2 numbers
Message-Id: <niab17.4hr.ln@flash.net>

Bill Jones (bill@fccj.org) wrote:
: Ronald J Kimball wrote:
: > 
: > Mike <support@counter.w-dt.com> wrote:
: > 
: > > How would you check the input then to make sure it has exactly two
: > > numbers inputed. Not more not less.
: > 
: > 2 == (() = /\d+/g);
: > 

: What about -

: unless ($number =~ /(\d+)/ && /^[1-99]$/) {
                                  ^^^^^^

   Your character class will match one of 9 characters.

   I don't know why you put the '9' character twice in the class...

   Character classes always match a single character. If you
   want more than one character, then you need to tack on
   a quantifier following the character class.



: Confusd...


  Yep  ;-)


--
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: Thu, 29 Oct 1998 18:33:48 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Easy Question: Rounding Numbers
Message-Id: <MPG.10a2c563ab8d7f19898ef@nntp.hpl.hp.com>

In article <UI8_1.7$kr5.134@nsw.nnrp.telstra.net> on Fri, 30 Oct 1998 
01:34:44 GMT, Martien Verbruggen <mgjv@comdyn.com.au> says...
> In article <71b4dv$fb6$1@supernews.com>,
> 	"Alistair Calder" <webmaster@topproducer.com> writes:
> > Well, thanks for helping me find it in the FAQ, but it still doesn't help
> > me.  I am obvoiusly not in the loop when it comes to understanding how to
> > use printf or sprintf.
> > 
> > I read through the manpages for both, but I got nothing out of how to format
> > variable $example so that it will round like this: xx.x or this: xx.xx
> 
> From the FAQ that you just read:
> 
>          printf("%.3f", 3.1415926535);       # prints 3.142
> 
> Hmm... I wonder if that 3 in %.3f means 'round at three decimals'.
> That would mena that if I change it to a two, it would round at two
> decimals. Maybe I should try it! While I am trying, I may as well use
> a variable instead of a constant.
 ... 
> If you need more help, I suggest you first try a few things, with the
> documentation in hand. You leanr most from just trying, and fiddling
> with these things.

Please give the guy a break, without the sarcasm.  I found that example 
in the FAQ that comes with perl 5.005.  However, there is *no* example 
in the FAQ that I found here:

http://www.perl.com/CPAN-
local/doc/FAQs/FAQ/PerlFAQ.html#Does_perl_have_a_round_function_

Is it not reasonable to assume that Perl programmers might look there as 
the *official* FAQ?  We keep telling them to...

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Thu, 29 Oct 1998 20:52:30 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Easy Question: Rounding Numbers
Message-Id: <fl9b17.4hr.ln@flash.net>

Alistair Calder (webmaster@topproducer.com) wrote:
: Well, thanks for helping me find it in the FAQ, but it still doesn't help
: me.  I am obvoiusly not in the loop when it comes to understanding how to
: use printf or sprintf.


   I'll try to explain it using small words  ;-)  ;-)


: I read through the manpages for both, but I got nothing out of how to format
: variable $example so that it will round like this: xx.x 


   printf "%4.2f\n", $_;  # min field width of 4, 2 decimal places

: or this: xx.xx


   printf "%5.2f\n", $_;  # min field width of 5, 2 decimal places

   printf "%05.2f\n", $_; # same, but use leading zeros instead of blanks


: I'm having some problems understanding how it works, I guess.  Can someone
: offer any more help?


   The "first" number specifies a minimum field width. Padded with
   blanks or zeros if number is shorter than the field width.

   The decimal point takes up one of the min field width positions.

   Will use more than the minimum field width if the number is too
   big to fit.

   The "second" number specifies the number of places to the
   right of the decimal point.



   Does that do it?

   If not, then just go try out a bunch of different combinations
   and see what they do.


--
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: Thu, 29 Oct 1998 20:35:43 -0500
From: Tk Soh <r28629@email.sps.mot.com>
Subject: Re: Easy Question: Rounding Numbers
Message-Id: <363917ED.D1DEB0F8@email.sps.mot.com>

Alistair Calder wrote:
[...]
> How do I turn this number:
> 
> 12.591237489
> 
> Into this one:
> 
> 12.6

$a = 12.591237489;
$b = sprintf "%.1f", $a;
print $b;
12.6

-tk


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

Date: Thu, 29 Oct 1998 20:25:54 -0500
From: Tk Soh <r28629@email.sps.mot.com>
Subject: Re: Need help appending a string to a hash
Message-Id: <363915A1.666F0853@email.sps.mot.com>

Martien Verbruggen wrote:
> 
> In article <363904B1.2EBD055B@email.sps.mot.com>,
>         Tk Soh <r28629@email.sps.mot.com> writes:
> 
> >>        }
> >>        $Fail_Vec{$2}++; # INCREMENT THE NUMBER OF FAILS
> >          ^^^^^^^^^^^^^^^
> > Oops, $Fail_Vec{$2} is a reference to array. Who know where is pointing
> > to now after getting incremented.
> 
> Nothing. It changes to a scalar.
> 
> #!/usr/local/bin/perl -w
> use strict;
> my $a = [1, 2, 3];
> print "$a, @$a\n";
> $a++;
> print "$a, ";
> print "@$a\n";
> 
> ARRAY(0xd9064), 1 2 3
> Can't use string ("888933") as an ARRAY ref while "strict refs" in use at ./tt.pl line 7.
> 888933,
> 

Agree, I meant to say the subsequent push() will go nowhere:

  DB<1>  %h = ('a'=> [1,2,3],'b'=>[4,5,6])

  DB<2> x \%h
0  HASH(0x199684)
   'a' => ARRAY(0x1e63b8)
      0  1
      1  2
      2  3
   'b' => ARRAY(0x1dc8e8)
      0  4
      1  5
      2  6
  DB<3> print hex '1e63b8'
1991608
  DB<4> $h{a}++

  DB<5> x \%h
0  HASH(0x199684)
   'a' => 1991609
   'b' => ARRAY(0x1dc8e8)
      0  4
      1  5
      2  6
  DB<6> push @{$h{a}}, 'xxx'

  DB<7> x \%h
0  HASH(0x199684)
   'a' => 1991609
   'b' => ARRAY(0x1dc8e8)
      0  4
      1  5
      2  6

-tk


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

Date: 29 Oct 1998 21:14:54 -0500
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Not to start a language war but..
Message-Id: <x7hfwmeqxt.fsf@sysarch.com>

>>>>> "JO" == Jason Orendorff <jorendorff@ixl.com> writes:

  JO> And where does the "max 80 column text" idea come from?
  JO> Calm down, brother!

80 columns are both historical and practical. punch cards started with
the 80 column width and letter size paper can handle 80 chars with 10
chars/in. most dumb terminals were 80 columns too. xterm and their vt100
companion simulators all have 80 column mode and that is the default in
most cases. even printing on a laser printer with a normal font size
will give only about 80 columns (same as a typewriter!).

even though i can make my editor wider than 80 columns i fnd that is a
good width to keep for reading and writing anything including code. long
code lines even when visible and not wrapped are annoying to me to read.

so 80 columns is real in both a practical and psychological manner.

deal with it. format your code to 80 columns for good of humanity. you
may stop the next war by doing this.

:-)

uri

-- 
Uri Guttman  -----------------  SYStems ARCHitecture and Software Engineering
Perl Hacker for Hire  ----------------------  Perl, Internet, UNIX Consulting
uri@sysarch.com  ------------------------------------  http://www.sysarch.com
The Best Search Engine on the Net -------------  http://www.northernlight.com


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

Date: 30 Oct 98 02:26:43 GMT
From: Zenin <zenin@bawdycaste.org>
Subject: Re: Not to start a language war but..
Message-Id: <909714669.18796@thrush.omix.com>

Jason Orendorff <jorendorff@ixl.com> wrote:
	>snip<
: And learn the semantics of bless's default arguments,

	Don't use them.  I have seen almost no code that actually
	does.  The existance of single argument bless() is a bug IMHO.

: and learn to appreciate the beauty of $x->{y} versus x.y  :-)

	Yes.

	>snip<
: Anyway, Perl allows a lot of silent errors throughout the
: language and libraries that would subvert any exception system
: you might claim exists.

	"Silent" errors?  What BS are you talking about?

: I'm not saying this is a bad thing, I'm
: just saying Perl doesn't have exceptions.

	Perl has had exceptions since version 1 (see recent followup in
	this same thread).

: >         Name a platform Python supports that Perl doesn't, I dare you.
:
: JVM.  What do I win?

	IMHO JVM isn't a platform until it can bootstrap itself.  When the
	famed JavaChips come out, I'll change my mind.

: Also, I'm curious about Windows CE; there's a Perl for Windows CE, right?

	Ok, you win there. -If you actually consider WinCE a platform. :-)

	>snip<
: >         Ever try 'perl -d'?
: Wow!  I just did, for the first time.  Better than I expected, actually.
: Well, at least something good came from this flame war.  :-)

	:-)

	>snip<
: The equivalent of all that Java in JPython is:
:     def append(self, x): self._extractStringBuffer().append(x); self.type = STRING; return self.string

	Interesting.  And all that forced indention was to be the holy grail
	of readability, one can throw it out at a whim, but only if one puts
	it all on one single line...  Interesting. :-)

: I hope you appreciate that; I had to reconfigure my mailer so it wouldn't
: wrap the line.  :-)  I would normally write it like this:
:
:     def append(self, x):
:         self._extractStringBuffer().append(x)
:         self.type = STRING
:         return self.string
:
: The Python code is loosely typed, but dispatches to the properly
: typed java methods.  Nice, eh?  Even if it is useless.  ;-)

	Ya seen JPL yet?  Forget dispatching anything, just code Java
	methods in pure Perl! :-)

: And where does the "max 80 column text" idea come from?
: Calm down, brother!

	Another pointless thread on readability.

-- 
-Zenin (zenin@archive.rhps.org)           From The Blue Camel we learn:
BSD:  A psychoactive drug, popular in the 80s, probably developed at UC
Berkeley or thereabouts.  Similar in many ways to the prescription-only
medication called "System V", but infinitely more useful. (Or, at least,
more fun.)  The full chemical name is "Berkeley Standard Distribution".


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

Date: 30 Oct 1998 02:43:55 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: Not to start a language war but..
Message-Id: <71b95b$m11$1@mathserv.mps.ohio-state.edu>

[A complimentary Cc of this posting was sent to Jon Drukman
<jsd@gamespot.com>],
who wrote in article <slrn73i4e3.9k9.jsd@hudsucker.gamespot.com>:
> unfortunately what it has lacked since day 1 (and still lacks) is a
> way of getting the built-in functions to generate exceptions.
> 
> anxiously awaiting "use Fatal",

Eh?

Ilya


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

Date: Thu, 29 Oct 1998 18:38:15 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Not to start a language war but..
Message-Id: <MPG.10a2c66e2529ff239898f0@nntp.hpl.hp.com>

[Posted to comp.lang.perl.misc and copy mailed.]

In article <36391D88.34EA64D9@ixl.com> on Thu, 29 Oct 1998 17:59:36 -
0800, Jason Orendorff <jorendorff@ixl.com> says...
 ...
> And where does the "max 80 column text" idea come from?

In addition to the history that Uri Guttman expounded on, it happens 
also to be the Usenet standard, for similar good reasons.  We are 
encouraged to set our line wraps at 72 columns in order that multiple 
quoting indents not push the lines over 80 columns.

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: 30 Oct 1998 02:34:10 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Perl & Y2K - booby trap code
Message-Id: <71b8j2$9c1$1@marina.cinenet.net>

David Formosa (dformosa@zeta.org.au) wrote:
: In article <718sv6$ctn$3@client3.news.psi.net>, Abigail wrote:
: 
: >I disagree that 0 .. 59 is correct. 61 is of course pure silliness,
: >but what do you expect from those who gave us year - 1900?
: 
: What about leap seconds?

Unix/POSIX time has no leap seconds.  It proceeds monotonically in
60-second minutes from the epoch.  In this, it is similar to ET (Ephemeris
Time).  Both are some number of seconds away from UTC at any given moment,
that number changing as leap seconds occur.  Note that nearly all
sysadmins set the system time so that the delta 'currently' is zero,
effectively using a new 'epoch' each time they set the system time. 

---------------------------------------------------------------------
   |   Craig Berry - cberry@cinenet.net
 --*--    Home Page: http://www.cinenet.net/users/cberry/home.html
   |      "Ripple in still water, when there is no pebble tossed,
       nor wind to blow..."


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

Date: 30 Oct 1998 02:37:57 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Perl & Y2K - booby trap code
Message-Id: <71b8q5$9c1$2@marina.cinenet.net>

Uri Guttman (uri@sysarch.com) wrote:
: i don't deny there are gotme's. yesterday i was stuck trying to get a
: slice from a hash ref. i have done this before but the syntax flew out
: of my brain. it took a little while longer than i wanted to get it
: right. that is my most recent gotme.

God, I'm glad I'm not the only one!  For whatever reason, my brain refuses
to store that syntax.  I have to rediscover it by trial and error every
time I need it (which isn't at all often; otherwise, it would probably
stick).

---------------------------------------------------------------------
   |   Craig Berry - cberry@cinenet.net
 --*--    Home Page: http://www.cinenet.net/users/cberry/home.html
   |      "Ripple in still water, when there is no pebble tossed,
       nor wind to blow..."


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

Date: Thu, 29 Oct 1998 20:00:30 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Perl & Y2K - booby trap code
Message-Id: <MPG.10a2d9bcfa9ebc0d9898f1@nntp.hpl.hp.com>

[Posted to comp.lang.perl.misc and copy mailed.]

In article <yl1znqhpfi.fsf@windlord.stanford.edu> on 29 Oct 1998 
16:19:13 -0800, Russ Allbery <rra@stanford.edu> says...
> Larry Rosler <lr@hpl.hp.com> writes:
 ... 
> ...  Point about documentation inconsistency taken, but
> unfortunately I think => is right to treat things beginning with - as
> words due to the number of people who think it's a cool way to do option
> parsing to pass in a hash or flattened hash with options beginning with
> -.  I personally utterly detest that style, but....

I have no feelings about the style, but I am beginning to 
understand and to detest the syntax.

   -foo => 'bar'

is parsed to

   '-' . 'foo' , 'bar'

which turns the semantics of 'unary minus' into chopped liver.  Not that 
there's anything wrong with that.  Chopped liver, I mean, not the 
syntactic goulash, which I now perceive to be a wart, plain and simple.  
But Perl DWIMming seems to require many such syntactic warts.

Coming from the relatively austere syntax of C, I find these warts to be 
rather disconcerting.  The contorted semantics that I quoted from perlop 
of so-called 'unary minus' (oops, I mean 'option-introducing flag'; 
maybe that should be added to the list of type indicators $ @ % * \ 
*AND* - [should I add a :-)?]) is anything but beautiful.  A clear 
example, IMH?O, of how the undeniable expressiveness of Perl springs to 
a large degree from unlovely syntactic irregularities (i.e., warts).

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: 29 Oct 1998 21:27:28 -0500
From: weijiang@pegasus.rutgers.edu (Alan Jiang)
Subject: remotely hosted access log
Message-Id: <71b86g$at2$1@pegasus.rutgers.edu>

Can anybody provide me some idea on how to write a script that collects
access data for a certain web page which is not on the same server where
the script resides (remotely hosted access logger, as it is called).
It should do something similar to the web site tracking service
provided  by usa.nedstat.net. Desired information include number of
hits, referer, client IP address, client agent name, etc. I know one
can obtain these data from environment variables only if the script is
embeded in the web page using SSI, or the whole page is generated by a
script. My guess is a remotely hosted script to work, it should make
use of HTTP protocal. But I have no clear idea how it works exactly.

Any helpful suggestions will be greatly apprciated.
Please reply to my email address at alan@raw.rutgers.edu.


Alan Jiang
Rutgers university


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

Date: Fri, 30 Oct 1998 02:44:58 GMT
From: ehpoole@ingress.com (Ethan H. Poole)
Subject: Re: remotely hosted access log
Message-Id: <KK9_1.2432$Qf3.4460@news9.ispnews.com>

[Posted and Emailed]  In article <71b86g$at2$1@pegasus.rutgers.edu>, 
weijiang@pegasus.rutgers.edu says...
>
>Can anybody provide me some idea on how to write a script that collects
>access data for a certain web page which is not on the same server where

You've already posted this to c.i.w.a.g, which is where this belongs.

Now, knowing that you have already identified the proper newsgroup, what was 
the rational to posting this in a Perl newsgroup?  Perl is not CGI and CGI is 
not Perl.

You'll get a reply in c.i.w.a.g a bit later, but in the future do NOT 
multipost like this.  Off topic posts only serve to irritate individuals who 
might otherwise be inclined to help.

-- 
Ethan H. Poole              | Website Design and Hosting,
                            | CGI Programming (Perl & C)..
========Personal=========== | ============================
* ehpoole @ ingress . com * | --Interact2Day--
http://home1.gte.net/ehp/   | http://www.interact2day.com/



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

Date: Fri, 30 Oct 1998 02:27:02 GMT
From: rstewart@vmirror.com (Bob Stewart)
Subject: Very Large DBM file: Finding Number of keys
Message-Id: <36392091.46273162@news.digex.net>

I need to log the number of unique IPs visiting my Web sites and then
be able to provide a monthly total.

For one of my sites, the number of unique IPs in a day is about 8,000
but will be double that by spring.  For the month, it will be in the
hundreds of thousands.

This seems to me to be the best way of doing it:
Have a dbm file for each month and as my log interpreter iterates
through the log file each night, have it also log the unique IPs.

Like:   $UNIQUE_IPS{$ip}++;

That way there will only be one key for every unique IP and I don't
have to sort, etc.

I don't really have to know what the IPs are, just how many. So I
should never need to use the keys function on my associative array.

I have two questions.

Is this probably the most efficient way of getting a list of the
unique IPs?

And my second question, is there a way of determining the number of
keys in an associative array without using the keys funtion?

The FAQ says to use the keys function, but that's a killer when you
have hauge number of records. 

Thanks!

Bob Stewart

rstewart@vmirror.com



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

Date: 29 Oct 1998 18:51:10 -0800
From: Russ Allbery <rra@stanford.edu>
Subject: Re: Very Large DBM file: Finding Number of keys
Message-Id: <yl90hyg3tt.fsf@windlord.stanford.edu>

Bob Stewart <rstewart@vmirror.com> writes:

> This seems to me to be the best way of doing it: Have a dbm file for
> each month and as my log interpreter iterates through the log file each
> night, have it also log the unique IPs.

> Like:   $UNIQUE_IPS{$ip}++;

> That way there will only be one key for every unique IP and I don't have
> to sort, etc.

[...]

> Is this probably the most efficient way of getting a list of the unique
> IPs?

Yes, almost certainly.

> And my second question, is there a way of determining the number of keys
> in an associative array without using the keys funtion?

Well, this is more a work-around than an alternate solution, but I'd do:

        if (++$UNIQUE_IPS{$ip} == 1) {
            $UNIQUE_IPS{TOTAL}++;
        }

and then just look at $UNIQUE_IPS{TOTAL} for the total number of unique
IPs seen so far.

-- 
#!/usr/bin/perl -- Russ Allbery, Just Another Perl Hacker
$^=q;@!>~|{>krw>yn{u<$$<[~||<Juukn{=,<S~|}<Jwx}qn{<Yn{u<Qjltn{ > 0gFzD gD,
 00Fz, 0,,( 0hF 0g)F/=, 0> "L$/GEIFewe{,$/ 0C$~> "@=,m,|,(e 0.), 01,pnn,y{
rw} >;,$0=q,$,,($_=$^)=~y,$/ C-~><@=\n\r,-~$:-u/ #y,d,s,(\$.),$1,gee,print


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

Date: Thu, 29 Oct 1998 20:07:05 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Very Large DBM file: Finding Number of keys
Message-Id: <MPG.10a2db423645562e9898f2@nntp.hpl.hp.com>

[Posted to comp.lang.perl.misc and copy mailed.]

In article <yl90hyg3tt.fsf@windlord.stanford.edu> on 29 Oct 1998 
18:51:10 -0800, Russ Allbery <rra@stanford.edu> says...
> Bob Stewart <rstewart@vmirror.com> writes:
 ... 
> > And my second question, is there a way of determining the number of keys
> > in an associative array without using the keys funtion?
> 
> Well, this is more a work-around than an alternate solution, but I'd do:
> 
>         if (++$UNIQUE_IPS{$ip} == 1) {
>             $UNIQUE_IPS{TOTAL}++;
>         }
> 
> and then just look at $UNIQUE_IPS{TOTAL} for the total number of unique
> IPs seen so far.

Er, Russ, you seem to have forgotten about

   scalar keys %UNIQUE_IPS

And Bob, I detest those all-caps identifiers, which by convention imply 
semantics that you don't mean.

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: 29 Oct 1998 20:44:59 -0800
From: Russ Allbery <rra@stanford.edu>
Subject: Re: Very Large DBM file: Finding Number of keys
Message-Id: <yliuh2d5f8.fsf@windlord.stanford.edu>

Larry Rosler <lr@hpl.hp.com> writes:
> Russ Allbery <rra@stanford.edu> says...

>> Well, this is more a work-around than an alternate solution, but I'd
>> do:

>>         if (++$UNIQUE_IPS{$ip} == 1) {
>>             $UNIQUE_IPS{TOTAL}++;
>>         }

>> and then just look at $UNIQUE_IPS{TOTAL} for the total number of unique
>> IPs seen so far.

> Er, Russ, you seem to have forgotten about

>    scalar keys %UNIQUE_IPS

No, I didn't.  If you can show me where in the documentation it promises
that keys in a scalar context won't simply build a list of all the keys
and then count the number of elements, I'll withdraw my suggestion.  :)

(I did check perlfunc, and I don't see a promise of that sort.)

-- 
#!/usr/bin/perl -- Russ Allbery, Just Another Perl Hacker
$^=q;@!>~|{>krw>yn{u<$$<[~||<Juukn{=,<S~|}<Jwx}qn{<Yn{u<Qjltn{ > 0gFzD gD,
 00Fz, 0,,( 0hF 0g)F/=, 0> "L$/GEIFewe{,$/ 0C$~> "@=,m,|,(e 0.), 01,pnn,y{
rw} >;,$0=q,$,,($_=$^)=~y,$/ C-~><@=\n\r,-~$:-u/ #y,d,s,(\$.),$1,gee,print


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

Date: Thu, 29 Oct 1998 21:18:12 -0500
From: Tk Soh <r28629@email.sps.mot.com>
To: Gordon Haverland <haverlan@agric.gov.ab.ca>
Subject: Re: Yet another list of lists question
Message-Id: <363921DF.782CE78F@email.sps.mot.com>

[posted and copy emailed]
Gordon Haverland wrote:
> 
> Hi.
>   I'm playing with some splines (piecewise polynomials).
> Within each segment, we have some number of coefficients
> representing the polynomial.  So $coeff[0] is the
> array of coefficents on the first segment of the spline.
> 
> I want to pass this array to a subroutine, and thinking a bit
> about efficiency, I figured a reference might be better.
> 
>   $f[0] += &subroutine( $begin, $end, \@coeff[$i] );
                                        ^^
    $f[0] += &subroutine( $begin, $end, $coeff[$i] );

>   local( $begin, $end, $r_coeff ) = @_;
>   ...
>      = $#{$r_coeff->[0]}
> or to access the j'th element
>      = $$r_coeff[0][$j]

    $elem_count = @{$r_coeff};
    $j_elem = $r_coeff->[$j];
    $last_elem_index = $#{$r_coeff};

> How should a person be doing this?  (I've looked in perldoc,
> man and dejanews, so if it is in the docs somewhere, my brain
> isn't working.)

perldoc perldsc

About your brain, go see a doctor . Have fun ;)

-tk


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

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


Administrivia:

Special notice: in a few days, the new group comp.lang.perl.moderated
should be formed. I would rather not support two different groups, and I
know of no other plans to create a digested moderated group. This leaves
me with two options: 1) keep on with this group 2) change to the
moderated one.

If you have opinions on this, send them to
perl-users-request@ruby.oce.orst.edu. 


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 4109
**************************************

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