[16914] in Perl-Users-Digest
Perl-Users Digest, Issue: 4326 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Sep 14 18:16:20 2000
Date: Thu, 14 Sep 2000 15:15:26 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <968969726-v9-i4326@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Thu, 14 Sep 2000 Volume: 9 Number: 4326
Today's topics:
Re: min function <jboes@eomonitor.com>
Re: O'Reilly University of Perl 2000 CGI$WWW Programmin (brian d foy)
passing arguments to <matchrule: $foo> in Parse::RecDes <ocschwar@mit.edu>
Re: Perl (Mark-Jason Dominus)
Re: print and CGI scripts <david.obrien@ssmb.com.au>
Problem with hashes (MQSeries) <psbrady@my-deja.com>
Re: Qualifications for new Perl programmer????? <nospam@david-steuber.com>
Re: Qualifications for new Perl programmer????? <nospam@david-steuber.com>
Re: Qualifications for new Perl programmer????? <russ_jones@rac.ray.com>
Re: Qualifications for new Perl programmer????? <smerr612@mailandnews.com>
Quality of rand() <doj@nortelnetworks.com>
Re: Quality of rand() (Chris Fedde)
Re: Quality of rand() (Mark-Jason Dominus)
Re: Quality of rand() <ren.maddox@tivoli.com>
Re: Quality of rand() <spragg@cs.ucdavis.edu>
Re: Regular Expressions <elijah@workspot.net>
Re: Req.: The perfect Perl Editor? (Mark-Jason Dominus)
Re: Req.: The perfect Perl Editor? <christopher_j@uswest.net>
Re: Req.: The perfect Perl Editor? (Mark-Jason Dominus)
Re: Sockets question nobull@mail.com
space available in hard disk for NT using perl <hopes@ole.com>
Re: sprintf() rounding problem <lr@hpl.hp.com>
Re: sprintf() rounding problem <russ_jones@rac.ray.com>
Re: storing HASH in HASH in DB_File ?? (janeways dream)
Re: Test Your Perl Skills (Richard J. Rauenzahn)
Re: Working with IP addresses <lr@hpl.hp.com>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 14 Sep 2000 16:49:31 -0400
From: Jeff Boes <jboes@eomonitor.com>
Subject: Re: min function
Message-Id: <39c139f9$0$51208$7aa13262@news.net-link.net>
sub min(@) {
die unless $ENV{SHELL} =~ /bash$/;
`echo \$(($_[0]<$_[1]?$_[0]:$_[1]))`;
}
8-)
--
Jeff Boes EoExchange, Inc.
Sr. Software Engineer (616) 381-9889 x.18
Search. Monitor. Notify. jboes@eoexchange.com
Aeneid is now EoExchange. http://www.eoexchange.com
------------------------------
Date: Thu, 14 Sep 2000 15:51:08 -0400
From: brian@smithrenaud.com (brian d foy)
Subject: Re: O'Reilly University of Perl 2000 CGI$WWW Programming in Perl class prerequisites
Message-Id: <brian-ya02408000R1409001551080001@news.panix.com>
In article <39C10D93.EF44E6FF@ugsolutions.com>, Ron Hill <hillr@ugsolutions.com> posted:
> According to the web page here is the prerequisites:
> intermediate to advanced Perl programmers who know Perl 5 and are
> familiar with the principles of CGI scripting.
have you tried asking O'Reilly? they've already asked me to respond
to a few such queries from potential attendees, so perhaps that
instructor (Dan Klein, i think) can clarify the requirements.
--
brian d foy
CGI Meta FAQ <URL:http://www.smithrenaud.com/public/CGI_MetaFAQ.html>
Perl Mongers <URL:http://www.perl.org/>
------------------------------
Date: Thu, 14 Sep 2000 17:11:28 -0400
From: Omri Schwarz <ocschwar@mit.edu>
Subject: passing arguments to <matchrule: $foo> in Parse::RecDescent
Message-Id: <39C13F00.C37F5B6F@mit.edu>
Hi, all. Just a quick one this time:
is it possible to pass arguments in <matchrule:> ?
<matchrule: $foo [bar => $baz]> won't parse.
<matchrule: $foo > [$bar => $baz]
won't DWIM or DWIW.
<matchrule: "$foo[bar=>$baz]"> won't work either.
I can use other methods to solve the problem at hand,
but I wonder if there's a way here.
------------------------------
Date: Thu, 14 Sep 2000 20:39:32 GMT
From: mjd@plover.com (Mark-Jason Dominus)
Subject: Re: Perl
Message-Id: <39c13783.3fef$19d@news.op.net>
In article <a17w5.404$0j.132182@news.uswest.net>,
Christopher M. Jones <christopher_j@uswest.net> wrote:
>B) Perl is not bad.
It's not bad, it just smells that way.
>C) Nor is it slow.
Could have fooled me!
------------------------------
Date: Fri, 15 Sep 2000 08:53:39 +1000
From: Dave O'Brien <david.obrien@ssmb.com.au>
Subject: Re: print and CGI scripts
Message-Id: <39C156F3.8C4BB1A0@ssmb.com.au>
Nick Condon wrote:
>
> Dave O'Brien wrote:
>
> > This seems like a simple proble, but I can't find any doco on it.
> >
> > I am writing a CGI script that takes some user settings, and then then
> > processes, and creates some new files.
>
> <snipped>
>
> > All I want to do, is temporarily redirect
> > print statements back to the terminal, and not the browser.
>
> But which terminal? Your CGI-processing webserver is presumely running as a
> daemon, and by definition daemons have no associated terminal.
>
> Give us an example (and ignore Godzilla)
> ---
> Nick
I'm sorry, but my first post was confusing. What I *should* have
written, was that I'm trying to *prevent* output to the browser from
print statements. The reason is that I'm using print statments to write
to a file, and they are currently showing up in the browser.
I suppose I could put a no response action on the CGI form (would this
work?), but I would like the page to output some status messages to the
user, so this isn't optimal.
thanks for your responses
Dave
------------------------------
Date: Thu, 14 Sep 2000 19:56:37 GMT
From: Paul Brady <psbrady@my-deja.com>
Subject: Problem with hashes (MQSeries)
Message-Id: <8praha$iiu$1@nnrp1.deja.com>
I've written a server module for an app using MQSeries, but having some
trouble unpacking values in the message header fields.
The client process I've written in perl to emulate the real client sets
the MsgDesc field as follows :
$MsgDesc = {
MsgSeqNumber => $msg_id
};
where $msg_id is a number (2 in my current test)
The server picks up the message, and check the $MsgDesc field. The
following is the output from my debug session :
p $MsgDesc
HASH(0x6d6984)
so I treat it as a hash and try to unpack it
p $$MsgDesc{"MsgSeqNumber"}
1
p $MsgDesc->{MsgSeqNumber}
1
I'd like to use this as a unique ID to track the transaction right
through the system, but it's no good unless I can get it to evaluate to
2 at the server end.
Any ideas ?
Also, I've built MQSeries on Solaris 2.6, Perl 5.6.0 using gcc. Had a
few problems there and had to change some MQ source and rebuild perl.
Where do I send the revised MQSeries module ?
Paul.
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Thu, 14 Sep 2000 18:38:29 GMT
From: David Steuber <nospam@david-steuber.com>
Subject: Re: Qualifications for new Perl programmer?????
Message-Id: <m3n1hastss.fsf@solo.david-steuber.com>
Brendon Caligari <bcaligari@my-deja.com> writes:
' I've learnt..maybe the hard way...that employers give you some money
' and you give them a piece of mind. however, the master copy...the idea
' behind a solution would still be in your mind...and that nobody can
' take a way :)
Don't be so sure... ;-)
' Whenever I worked on something I'm proud of whose source code I
' couldn't keep, I tend to write it down in my 'projects' resume...even
' just to keep track of what I'm done....especially when trying to sell
' myself. Many problems I cracked on a job I ended up re-coding more
' generically for myself too. Case in point was years ago..wrote a
' terminal emulator (ansi) for integration into a program that dialled an
' online service. The program was coded in turbo pascal. Re-wrote the
' emulator in C, and it got me a small contract for some similar work :)
I think I will steal your ideas, if I can. Much of the code I've
written for others has been rather specific to a problem domain and
not easily generalized. Still, after all this time, it's not too late
to start building up some sort of portfolio.
' upsetting was a book review i saw when hunting for perl books a few
' months ago. the review said that the book teaches perl even if you
' don';t have any programming experience.
Cookbook programming, AKA, recipes for disaster. Perl is a very nice
language in many ways and a hidious language in others. I find that
my past C/C++ (mostly the latter) experience has been very helpful in
some ways and hurtfull in others. What? No main()?! At least there
is strict. And once I get references down, I can get into OO. In the
meantime, I can use modules without necessarily knowing how they
work.
As for what I snipped about you using a non-module way of accessing
web pages, my first script that did that (for stealing dilbert
cartoons) used the language socket and io facilities, no modules. I
did rather crude HTTP by brute force. It worked.
' I'll shoot the next guy I meet who'll say that he wants to learn
' programming and is therefore going to learn perl, vb, c..whatever.
' Come across too many so called programmers, who have no idea what
' something as basic as recursion is.
Need ammo?
I hear Perl is not so hot with recursion. I haven't had occasion to
try that out yet though. Fortunatly, any recursive algorithm can be
converted into an iterative algorithm, no matter how painful a tree
traversal may be ;-).
' >
' > A good programmer can get a job done in just about any language. A
' > bad programmer can't get anything done in any language.
'
' A good programmer will give you a solution that will work for all the
' problem space. A bad programmer will give you a vb program for which
' there exists scenarios for whcih the expected results are returned.
If you are lucky.
--
David Steuber | Perl apprentice, Apache/mod_perl user, and
NRA Member | general Internet web wannabe.
------------------------------
Date: Thu, 14 Sep 2000 18:56:19 GMT
From: David Steuber <nospam@david-steuber.com>
Subject: Re: Qualifications for new Perl programmer?????
Message-Id: <m3k8cessz1.fsf@solo.david-steuber.com>
andrew-johnson@home.com (Andrew Johnson) writes:
' OK, you'll shoot a beginner who wants to start with Perl, VB, or C --
' what language would you recommend they start with ... oh, you already
' shot them, I guess you won't be recommending anything to them.
What you do is wear your most devilish grin and point that person to
"The Art Of Computer Programming" By Donald E. Knuth. Let them learn
MIX <eg!>!!!
Seriously, I personally learned with pseudocode. It was an algol like
deal for a Fortran class. It even covered recursion, something
Fortran 77 did not do easily (pass by reference).
There are certain little things like loops, functions, data types,
etc, that one must know about to understand programming. I certainly
wouldn't recomend Perl to a beginner (no programming experience at
all). I would probably recomend Tcl or Python. VB is very bad. C is
a great language, but it seems people have problems with it. C is the
first language I started to understand what everything was all about.
Pascal works too, but it is not a language I've warmed up to for some
reason.
Unfortunately, I learned C in a DOS environment and have not had the
opertunity to transfer all that experience over to Unix (Linux). I
don't know how to write GNU makefiles. I will pick that up when I
have a chance. Then there is using GDB as a debugging tool. Yuck!
There are others like DDD. I will have to look around, but it seems
that GDB 5.0 is most likely to be able to deal with GCC 2.95.2 and all
the latest features like pthreads.
My current work is all in Perl right now. This is something of a
crash course for me as I only know some of the language fundementals.
I keep the camel and the llama next to me at all times. I've also got
the cheetah on hand which has proven to be useful beyond DBI.
I guess you can throw a beginner at "Learning Perl" by Schwartz &
Christiansen. Do it in Unix, not Win32. Go through the book and do
all the exercises. The book does have the virtue of teaching some
basic programming as well as Perl. In the end though, it will not
make you a programmer. But it is a start.
--
David Steuber | Perl apprentice, Apache/mod_perl user, and
NRA Member | general Internet web wannabe.
------------------------------
Date: Thu, 14 Sep 2000 14:27:33 -0500
From: Russ Jones <russ_jones@rac.ray.com>
Subject: Re: Qualifications for new Perl programmer?????
Message-Id: <39C126A5.9D0D15D4@rac.ray.com>
Brendon Caligari wrote:
>
> introductory perl programming books are fine....bought "learning
> perl" and although I didn't like it, i think it's a good book.
> "programming perl" i liked, and "advanced perl programming" i adhored.
>
Do you mean "adored" or "abhorred?" Big diff!
--
Russ Jones - HP OpenView IT/Operatons support
Raytheon Aircraft Company, Wichita KS
russ_jones@rac.ray.com 316-676-0747
Quae narravi, nullo modo negabo. - Catullus
------------------------------
Date: Thu, 14 Sep 2000 20:38:36 GMT
From: Steven Merritt <smerr612@mailandnews.com>
Subject: Re: Qualifications for new Perl programmer?????
Message-Id: <8prd0a$ls2$1@nnrp1.deja.com>
In article <MPG.14292f9e9342de2d98978b@localhost>,
jason <elephant@squirrelgroup.com> wrote:
> Steven Merritt <smerr612@mailandnews.com> wrote ..
> >I didn't have trouble with your quiz, even though you did some
naughty
> >things like array names made up of punctuation and <STDIN> when STDIN
is
> >the default for <>(Assuming no arguements).
>
> array names made up of punctuation ? .. do you mean scalar names ? ..
or
> did the surrounding single quotes in question 6 confuse you ?
We can chalk this one up to Deja being a crappy newsreader. With the
font it used(and the screen resolution I run at) @x looked a fair bit
like @( in question 7. I used the feature I hope Deja never drops
(View original usenet format) and saw the difference.(or maybe I just
need new glasses)
Steven
--
King of Casual Play
The One and Only Defender of Cards That Blow
My newsreader limits sigs to four lines, but I cleverly bypassed this by
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Thu, 14 Sep 2000 14:34:28 -0400
From: "Dave Ockwell-Jenner" <doj@nortelnetworks.com>
Subject: Quality of rand()
Message-Id: <8pr5nm$fbg$1@bcrkh13.ca.nortel.com>
I'm using rand() to implement a very simple load-balancing redirect script
on the NT4 platform. The system primes the pseudo-random sequence with the
call srand() and then calles rand() to produce a random number (eventually
resulting in a server name). Anyway... here's the code snippet:-
srand();
my ($index) = rand($#game_servers);
$index = sprintf("%.0f", $index);
my ($server) = $game_servers[$index];
... so @game_servers holds a list of server names and the code tries to set
$server to be a random choice from that list.
I'm finding that the first and last elements of @game_servers are being
selected less frequently than any other - is this a quality issue with
rand(), or my use of it?
Thanks,
Dave.
------------------------------
Date: Thu, 14 Sep 2000 19:39:17 GMT
From: cfedde@u.i.sl3d.com (Chris Fedde)
Subject: Re: Quality of rand()
Message-Id: <FP9w5.145$W3.171109376@news.frii.net>
In article <8pr5nm$fbg$1@bcrkh13.ca.nortel.com>,
Dave Ockwell-Jenner <doj@nortelnetworks.com> wrote:
[...]
>$index = sprintf("%.0f", $index);
[...]
>
>I'm finding that the first and last elements of @game_servers are being
>selected less frequently than any other - is this a quality issue with
>rand(), or my use of it?
>
You are being hurt by rounding here. Consider that both 4.6 and
5.4 round to 5. At the bottom of the range there is nothing below
to round up and at the top of the range there is nothing above to
round down. Thus the end points get half the desired hits.
Use a different trunking technique. I'd suggest simply using int($index)
chris
--
This space intentionally left blank
------------------------------
Date: Thu, 14 Sep 2000 19:46:20 GMT
From: mjd@plover.com (Mark-Jason Dominus)
Subject: Re: Quality of rand()
Message-Id: <39c12b0b.3b5d$2b3@news.op.net>
[Mailed and posted]
In article <8pr5nm$fbg$1@bcrkh13.ca.nortel.com>,
Dave Ockwell-Jenner <doj@nortelnetworks.com> wrote:
>srand();
>my ($index) = rand($#game_servers);
>$index = sprintf("%.0f", $index);
>my ($server) = $game_servers[$index];
>
>I'm finding that the first and last elements of @game_servers are being
>selected less frequently than any other - is this a quality issue with
>rand(), or my use of it?
It's your use of it.
Let's suppose for concreteness that @game_servers has 4 elements.
$#game_servers is the index of the last element of @game_servers,
which is 3, because the 4 elements have indices 0, 1, 2, and 3.
So your 'rand' call looks like 'rand(3)'.
This generates a random number between 0 and 2.99999999999.
sprintf() rounds this off to the nearest integer.
If $index was between 0 and 0.4999999 the rounded result is 0
If $index was between 0.5 and 1.4999999 the rounded result is 1
If $index was between 1.5 and 2.4999999 the rounded result is 2
If $index was between 2.5 and 2.9999999 the rounded result is 3
0 0.5 1 1.5 2 2.5 3
+-----------------------------------------------+
|-- 0 --|
|------ 1 ------|
|------ 2 ------|
|-- 3 --|
So look: You get the results 1 and 2 exactly twice as often as you get
0 and 3.
The right way to select an element from an array at random is like
this:
my $index = rand(@game_servers);
$index = int($index);
my $server = $game_servers[$index];
In the first line, Perl sees that you have used an array in a place
where it expected a number. Whenever you use an array in a place
where Perl expects a number, Perl uses the number of elements from the
array. If @game_servers has 4 elements, Perl uses the number 4 here.
This generates a random number between 0 and 3.99999999999.
int() throws away the fractional part and keeps the integer part of
this number.
If $index was between 0 and 0.9999999 the rounded result is 0
If $index was between 1 and 1.9999999 the rounded result is 1
If $index was between 2 and 2.9999999 the rounded result is 2
If $index was between 3 and 3.9999999 the rounded result is 3
0 0.5 1 1.5 2 2.5 3 3.5 4
+---------------------------------------------------------------+
|------ 0 ------|
|------ 1 ------|
|------ 2 ------|
|------ 3 ------|
Now all four bars are the same size, so the servers are being selected
with the same probability.
my $index = rand(@game_servers);
$index = int($index);
my $server = $game_servers[$index];
There's no reason to do the rand() and the int() in separate statements:
my $index = int(rand(@game_servers));
my $server = $game_servers[$index];
$index is synthetic, and we might as well get rid of it if we aren't
going to use it again:
my $server = $game_servers[int(rand(@game_servers))];
Actually, Perl does int() automatically on array indices, because
array indices must be integers. So we can leave out the int() here:
my $server = $game_servers[rand(@game_servers)];
That's how you select a random element from an array in Perl.
------------------------------
Date: 14 Sep 2000 14:32:40 -0500
From: Ren Maddox <ren.maddox@tivoli.com>
Subject: Re: Quality of rand()
Message-Id: <m34s3i22hz.fsf@dhcp11-177.support.tivoli.com>
"Dave Ockwell-Jenner" <doj@nortelnetworks.com> writes:
>
> srand();
> my ($index) = rand($#game_servers);
> $index = sprintf("%.0f", $index);
> my ($server) = $game_servers[$index];
>
> ... so @game_servers holds a list of server names and the code tries to set
> $server to be a random choice from that list.
>
> I'm finding that the first and last elements of @game_servers are being
> selected less frequently than any other - is this a quality issue with
> rand(), or my use of it?
First, as of version 5.004, calling rand automatically calls srand if
it hasn't yet been called. So unless you are going to pass an
argument to srand, there really isn't any point in calling it.
Your problem is that you are using sprintf and it is not doing what
you expect. You're basically converting the range 0 - .5 to 0, and
(assuming $#game_servers is 9) 9.5 - 9.99... to 10. So 0 and 10 only
get half as many hits as the rest of the numbers.
Instead, just use "int" (or don't, you actually don't need anything --
see below) and just increase your argument to "rand" by one (so use
"rand @game_servers").
Here is a little script that demonstrates the problem (and the
effectiveness of the solutions).
% perl <<'EOF'
while (my $code = <DATA>) {
my @number;
for (1 .. 5_000) {
$number[eval $code]++;
}
print "@number ==> $code";
}
__DATA__
sprintf "%.0f", rand 9
int rand 10
rand 10
EOF
275 590 548 573 528 563 568 551 526 278 ==> sprintf "%.0f", rand 9
497 461 522 500 526 482 495 491 500 526 ==> int rand 10
522 458 479 481 510 539 507 505 506 493 ==> rand 10
I didn't benchmark these, but it was pretty evident in my testing that
the "int" solution is significantly faster than the "sprintf"
solution. Likewise, leaving the int off makes a small but noticeable
difference.
Oh, what they hay... adding Benchmark to the above code is trivial.
Here are my results:
int rand 10: 2 wallclock secs
( 1.65 usr + 0.00 sys = 1.65 CPU) @ 606060.61/s (n=1000000)
rand 10: 0 wallclock secs
( 1.03 usr + -0.07 sys = 0.96 CPU) @ 1041666.67/s (n=1000000)
sprintf "%.0f", rand 9: 20 wallclock secs
(20.63 usr + 0.04 sys = 20.67 CPU) @ 48379.29/s (n=1000000)
Just for completeness, here is how I would write what you wrote:
my $server = $game_servers[rand @game_servers];
--
Ren Maddox
ren@tivoli.com
------------------------------
Date: 14 Sep 2000 20:20:33 GMT
From: Adam Trace Spragg <spragg@cs.ucdavis.edu>
Subject: Re: Quality of rand()
Message-Id: <8prbuh$9nn$2@mark.ucdavis.edu>
Mark-Jason Dominus <mjd@plover.com> wrote:
: It's your use of it.
[snip]
What a completely helpful answer! It wasn't my question, but thanks!
Adam
------------------------------
Date: 14 Sep 2000 21:06:24 GMT
From: Eli the Bearded <elijah@workspot.net>
Subject: Re: Regular Expressions
Message-Id: <eli$0009141706@qz.little-neck.ny.us>
In comp.lang.perl.misc, Abigail <abigail@foad.org> wrote:
> *ANY* character can appear in an email address.
>
> \<@example.com
>
> is a valid address.
That example is valid, but that does not make your first statement
above valid. Control characters and highbit characters are specifically
forbidden, though with modern software many of them will work.
(I used "\b@qz.to" (where \b is backspace, per perl conventions) with
sendmail and had no MTA problems. MUA is another matter.)
Elijah
------
no longer uses any qz.to addresses
------------------------------
Date: Thu, 14 Sep 2000 20:49:57 GMT
From: mjd@plover.com (Mark-Jason Dominus)
Subject: Re: Req.: The perfect Perl Editor?
Message-Id: <39c139f5.4036$1d@news.op.net>
In article <slrn8s0tfu.4t8.tim@degree.ath.cx>,
Tim Hammerquist <tim@degree.ath.cx> wrote:
> pico
I find pico impossible because it doesn't do line numbering. When the
compiler says you have an error on line 57, you have to count 57 lines
down manually.
------------------------------
Date: Thu, 14 Sep 2000 14:10:33 -0700
From: "Christopher M. Jones" <christopher_j@uswest.net>
Subject: Re: Req.: The perfect Perl Editor?
Message-Id: <c9bw5.528$0j.247825@news.uswest.net>
"Mark-Jason Dominus" <mjd@plover.com> wrote:
> In article <slrn8s0tfu.4t8.tim@degree.ath.cx>,
> Tim Hammerquist <tim@degree.ath.cx> wrote:
> > pico
>
> I find pico impossible because it doesn't do line numbering. When the
> compiler says you have an error on line 57, you have to count 57 lines
> down manually.
>
On many versions of pico you can press ctrl-C and get a line and
character number.
Here's an example:
[ line 127 of 1040 (12%), character 4756 of 34663 (13%) ]
------------------------------
Date: Thu, 14 Sep 2000 21:59:14 GMT
From: mjd@plover.com (Mark-Jason Dominus)
Subject: Re: Req.: The perfect Perl Editor?
Message-Id: <39c14a31.42ab$113@news.op.net>
In article <c9bw5.528$0j.247825@news.uswest.net>,
Christopher M. Jones <christopher_j@uswest.net> wrote:
>On many versions of pico you can press ctrl-C and get a line and
>character number.
>
>Here's an example:
>
>[ line 127 of 1040 (12%), character 4756 of 34663 (13%) ]
In that case you still have to do binary search to find the line you want.
------------------------------
Date: 14 Sep 2000 18:52:39 +0100
From: nobull@mail.com
Subject: Re: Sockets question
Message-Id: <u9d7i6svx4.fsf@wcl-l.bham.ac.uk>
Larry Swartwood <lhswartw@ichips.intel.com> writes:
> I am receiving the following error when running my client/server script:
>
> Bad arg length for Socket::unpack_sockaddr_in, length is 1, should be 16
> at Socket.pm line 311.
Ouch, the old-style socket interface is really hard to use. I
recommend using IO::Socket.
> In the script I setup a client and server like so:
[snip partial code]
> I receive the error when my server accepts an incoming connection
So this would be in a part of the code you that didn't show us.
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Thu, 14 Sep 2000 20:14:34 +0200
From: "Hopes" <hopes@ole.com>
Subject: space available in hard disk for NT using perl
Message-Id: <8pr4e1$4ur$1@diana.bcn.ttd.net>
¿Could anyone tell me if it is possible (and simple) to find the space
available in a NT machine using Perl?
Thanks to all
------------------------------
Date: Thu, 14 Sep 2000 12:39:41 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: sprintf() rounding problem
Message-Id: <MPG.142ac95c2539edad98ad67@nntp.hpl.hp.com>
In article <968934567.255958610@news.uklinux.net> on Thu, 14 Sep 2000
13:15:42 +0100, David Hugh-Jones <davidhj@mail.com> says...
...
> I assume the problem is that weird floating point arithmetic stuff is
> making 6698 be really a bit less than 6698 before it gets integerized. But I
> don't know how to work around this. One option that comes up is "do everything
> in cents so you are working with integers internally". Unfortunately, I can't
> do that, because my program takes external input in the form of dollars and
> cents (or pounds and pence). It would be too difficult to make users calculate
> everything in cents. So, I have to use floating point numbers.
Why do the users have to calculate everything in cents? Multiply their
input by 100 immediately, work with cents internally, then convert back
on output.
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Thu, 14 Sep 2000 15:47:45 -0500
From: Russ Jones <russ_jones@rac.ray.com>
Subject: Re: sprintf() rounding problem
Message-Id: <39C13971.3FBA8051@rac.ray.com>
Larry Rosler wrote:
>
> Why do the users have to calculate everything in cents? Multiply their
> input by 100 immediately, work with cents internally, then convert back
> on output.
>
Users want to calculate in dollars (and hundredths of a dollar). So,
like you say, multiply dollars by 100 and you're working in cents. Of
course, if you want to divide your ill-gotten gains three ways, or
want to compute seven percent interest, compounded daily, you're still
going to have rounding.
One of the earliest computer banking scams involved some careful
truncation made to look like rounding. It can add up.
--
Russ Jones - HP OpenView IT/Operatons support
Raytheon Aircraft Company, Wichita KS
russ_jones@rac.ray.com 316-676-0747
Quae narravi, nullo modo negabo. - Catullus
------------------------------
Date: Wed, 13 Sep 2000 13:28:13 GMT
From: JanewaysDream@StarTrekmail.com (janeways dream)
Subject: Re: storing HASH in HASH in DB_File ??
Message-Id: <39bf7fd3.665143@news.connect.ab.ca>
On Tue, 12 Sep 2000 23:53:59 GMT, JanewaysDream@StarTrekmail.com
(janeways dream) wrote:
>on PERSONAL WEB SERVER, running ACTIVE STATE PERL
UPDATE!!! I found out how to makw this work!!! its solved!!!
there is a special module for PERL called MLDBM which you
use to wrap around the DB_File like this....
----
use MLDBM qw(DB_File);
use Fcntl;
***then you can TIE to your hearts content:
tie %d2, 'MLDBM', "cgi-bin/cnts/$thebase", O_CREAT | O_RDWR, 0666;
%d2 = (
flinstones => {
lead => 'fred',
wife => 'wilma',
son => 'bambam',
},
jetsons => {
lead => 'george',
wife => 'jane',
son => 'elroy',
},
simpsons => {
lead => 'homer',
wife => 'marge',
son => 'bart',
}
);
untie %d2;
NOW YOU CAN REFERENCE CONTENTS IN THE DBM LIKE THIS
$d2{'flinstones'}{'lead'}
which would be as above, equal to "fred"
cheers!! and hooray!
------------------------------
Date: 14 Sep 2000 21:00:58 GMT
From: nospam@hairball.cup.hp.com (Richard J. Rauenzahn)
Subject: Re: Test Your Perl Skills
Message-Id: <968965256.842739@hpvablab.cup.hp.com>
brian@smithrenaud.com (brian d foy) writes:
>In article <968876230.661951@hpvablab.cup.hp.com>,
>nospam@hairball.cup.hp.com (Richard J. Rauenzahn) posted:
>
>> tony@svanstrom.com (Tony L. Svanstrom) writes:
>> >Which is why managers love it and only hire people with papers that says
>> >that they know something, without bothering to even look at people that
>> >really knows it.
>>
>> I'll never get hired. I failed this question:
>>
>> If $a is TRUE, and $b is TRUE, which of the following yield a true result?
>>
>> a. $a && $b
>> b. $a
>> $b
>> c. ! $a
>>
>> It says $a|$b is the right answer. [No, that isn't a cut & paste error
>> above.]
>
>well, at least (a) is true. the short circuit operators return
>the last evaluated expression. is the answer "$a|$b" even
>an option?
>
>> In pattern matching, how do you match an octal value?
>>
>> a. \nnn (where nnn is that octal value)
>> b. \onnn (that's the letter 'o')
>> c. %onnn ( that's the letter 'o')
>> d. ^onnn ( that's the letter 'o')
>> e. \O ( that's the letter 'O')
>>
>> Obviously, the answer is (a)!
>
>maybe. it has to be a valid octal value. perhaps the
>question meant to specify { n a member of (0,1,2,3,4,5,6,7) }.
>even then, the first digit has to be in the right range.
>
>
>> Which character sequence will match a word boundary?
>>
>> a. /b
>> b. /c
>> c. /t
>> d. /w
>> e. none
>>
>> Again, the answer is (a).
>
>are you sure that you typed that correctly? none of those
>are regex assertions. perhaps you meant \b ?
>
>--
>brian d foy
>CGI Meta FAQ <URL:http://www.smithrenaud.com/public/CGI_MetaFAQ.html>
>Perl Mongers <URL:http://www.perl.org/>
--
Rich Rauenzahn ----------+xrrauenza@cup.hp.comx+ Hewlett-Packard Company
Technical Consultant | I speak for me, | 19055 Pruneridge Ave.
Development Alliances Lab| *not* HP | MS 46TU2
ESPD / E-Serv. Partner Division +--------------+---- Cupertino, CA 95014
------------------------------
Date: Thu, 14 Sep 2000 12:31:01 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Working with IP addresses
Message-Id: <MPG.142ac752f777174b98ad66@nntp.hpl.hp.com>
In article <8pqrgf$qn0$1@news.smart.net> on 14 Sep 2000 15:39:59 GMT,
hymie! <hymie@lactose.smart.net> says...
...
> Convert the two IP addresses from base-256 numbers into base-10 numbers.
> Then, as you iterate between your starting and ending point, convert
> the base-10 numbers back to base-256 IP addresses.
>
> $base10=unpack("L",join '',map chr,reverse split(/\./,$ip));
>
> $ip = join '.',unpack("C*",reverse pack ("L",$base10));
You are seriously deluded to think that those are 'base-10' numbers.
That is only how they appear if you print them (that is, the default
conversion of an integer to a string uses base-10 notation). They are
simply integers using Perl's internal representation, which is binary-
based.
> (Now ... I'm very proud of this little snippet, because I'm Just Another
> Perl Hacker Wannabe. So I'm not sure if I should invite you to admire
> it, or pick it apart and teach me. :)
It is pretty good, though you missed the pack() in the first conversion.
But it is seriously flawed by the use of the endian-dependent 'L'
conversion, instead of always big-endian 'Network' order.
$number=unpack'N',pack'C4',split/\./,$ip;
$ip=join'.',unpack'C4',pack'N',$number;
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 16 Sep 99)
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.
| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.
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.
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 V9 Issue 4326
**************************************