[8735] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 2353 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Apr 17 17:07:27 1998

Date: Fri, 17 Apr 98 14:01:38 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Fri, 17 Apr 1998     Volume: 8 Number: 2353

Today's topics:
    Re: regular expression question <kapur@cbl.ncsu.edu>
    Re: regular expression question <rootbeer@teleport.com>
    Re: shorten array <rootbeer@teleport.com>
    Re: shorten array johnnie@NOPERSONALMAIL.edu
    Re: Snobby news group <rootbeer@teleport.com>
    Re: Snobby news group <bmb@ginger.libs.uga.edu>
    Re: Snobby news group (Greg Bacon)
    Re: Snobby news group <andrewf@cp.pathfinder.com>
    Re: Snobby news group <andrewf@cp.pathfinder.com>
    Re: Snobby news group <zenin@archive.rhps.org>
    Re: srand and rand fx <rootbeer@teleport.com>
    Re: srand and rand fx (Chris Nandor)
        statically link modules: how to? (John Edstrom)
        Undef vs. Empty Anon Array ([]) as subroutine parameter <achoy@us.oracle.com>
    Re: Undef vs. Empty Anon Array ([]) as subroutine param <jdporter@min.net>
    Re: Wanna laugh?  (My First cgi.pm Script) (John Klassa)
    Re: What does "Illegal modulus zero" mean? <rootbeer@teleport.com>
    Re: What does "Illegal modulus zero" mean? (Charles DeRykus)
        Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: 17 Apr 1998 15:25:26 -0400
From: Nevin Kapur <kapur@cbl.ncsu.edu>
Subject: Re: regular expression question
Message-Id: <tyn2dk45eh.fsf@cbl.ncsu.edu>

doswald@xmission.com (David Oswald) writes:

> On Thu, 16 Apr 1998 21:34:55 -0600, jcartwright@wans.net (John
> Cartwright) wrote:
> 
> >Hello All,
> >
> >I'm trying to build a regular expression that will return only the
> >signifigant digits to the right of the decimal point.  For instance, if my
   ^^^^^^^^^^^^^^^^^^
> >value is "1.01200", what I would like to get back is "012".  Although I've
> >tried a number of alternatives, I was using something like:
> 
> /\.(\d+?)0*$/

Two observations:

1. Is the greedy match really necessary? Observe:

  DB<8> $number = 1.25000 
 
  DB<9> ($sig) = $number =~ /\.(\d+)0*$/;
 
  DB<10> p $sig
25

Actually, I am curious as to why this does not return 25000 - I assume
that this happens because of the left-to-right pecking order mentioned
in the Blue Camel on p. 62. I'd appreciate a correction.

2. A nit pick: the 0s in 1.25000 are *significant*. A quote from
"Math With Significant Figures":
http://dbhs.wvusd.k12.ca.us/SigFigMath-MultDiv.html
   
   A common error is for the
   student to look at a number like 3.10 and think it has two significant
   figures. The zero in the hundedth's [sic] place is not recognized as
   significant when, in fact, it is. 3.10 has three significant figures.
-- 
Nevin


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

Date: Fri, 17 Apr 1998 19:54:07 GMT
From: Tom Phoenix <rootbeer@teleport.com>
To: Nevin Kapur <kapur@cbl.ncsu.edu>
Subject: Re: regular expression question
Message-Id: <Pine.GSO.3.96.980417125002.8799Q-100000@user2.teleport.com>

On 17 Apr 1998, Nevin Kapur wrote:

> > On Thu, 16 Apr 1998 21:34:55 -0600, jcartwright@wans.net (John
> > Cartwright) wrote:

> > >value is "1.01200", 

> > /\.(\d+?)0*$/
> 
> Two observations:
> 
> 1. Is the greedy match really necessary? Observe:
> 
>   DB<8> $number = 1.25000 

Perhaps you didn't observe that that's not the same as the original value
- which is a string. 1.25000 is the same as 1.25, but neither is the same
as "1.25000". 

Of course, there's no guarantee that that pattern will pick out the proper
fractional part of a Perl number, since a Perl number may look like
'123.45e-67', for example. :-)

Hope this helps!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Fri, 17 Apr 1998 19:07:19 GMT
From: Tom Phoenix <rootbeer@teleport.com>
To: John Blanco <johnnie@holly.colostate.edu>
Subject: Re: shorten array
Message-Id: <Pine.GSO.3.96.980417120258.8799H-100000@user2.teleport.com>

On Fri, 17 Apr 1998, John Blanco wrote:

> @words = ('lets', 'go', 'mets');
> 
> srand;
> while(@words) {
>    $random_word = splice(@words, rand $#words, 1);
>    print "$random_word\n";
> }

This algorithm has an important flaw: Whichever word is last in @words
will always be the last one chosen. Nice try, though!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/




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

Date: 17 Apr 1998 13:38:28 -0600
From: johnnie@NOPERSONALMAIL.edu
Subject: Re: shorten array
Message-Id: <6h8b3k$6d88@holly.ColoState.EDU>

John Blanco <johnnie@holly.colostate.edu> bravely wrote:
: ~arthur wrote:

: @words = ('lets', 'go', 'mets');

: srand;
: while(@words) {
:    $random_word = splice(@words, rand $#words, 1);
:    print "$random_word\n";
: }

   Whooops!  Got my languages mixed up! :)  rand returns 0 .. $arg-1.  So
fix the above code by changing (rand $#words) to (rand scalar(@words))
Sorry! :)

   - Johnnie B
-- 
   - Johnnie Blanco Jr.
   - The Kilauea Caldera @ http://holly.colostate.edu/~johnnie
   - "You always seem to find my faults; faster than you find your own."
   -    Tori Amos [Upside Down]


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

Date: Fri, 17 Apr 1998 19:19:48 GMT
From: Tom Phoenix <rootbeer@teleport.com>
To: Database Coder <dbcoder@juno.com>
Subject: Re: Snobby news group
Message-Id: <Pine.GSO.3.96.980417121900.8799J-100000@user2.teleport.com>

On Fri, 17 Apr 1998, Database Coder wrote:

> Why is this such a snobby unhelpful news group. I have posted in many
> other news groups and always recieved polite and helpful responses. This
> news group is the exception. The amount of time you people spend asking
> people if they read the FAQ or bought a good book on PERL could have
> been spent helping the person. 

Asking people _to_ read the FAQ or _to_ buy a good book on Perl actually
does help them. Nothing snobby about that! :-)

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Fri, 17 Apr 1998 15:59:47 -0400
From: Brad Baxter <bmb@ginger.libs.uga.edu>
Subject: Re: Snobby news group
Message-Id: <Pine.A41.3.96.980417154819.63622T-100000@ginger.libs.uga.edu>

I have posted in many other groups, also, and have *not* always received
responses as nice as I <pompous>myself</pompous> might give.  I have
occasionally dropped groups for that reason.  This is one group I'll
likely stick with for what I think are important reasons.  I've already
had sufficient reason to feel that the blossoms are worth the thorns.

Stick around.  You'll be a positive influence. :-)

Brad Baxter
UGA


On Fri, 17 Apr 1998, Database Coder wrote:
> Why is this such a snobby unhelpful news group. I have posted in many other
> news groups and always recieved polite and helpful responses. This news
> group is the exception. The amount of time you people spend asking people if
> they read the FAQ or bought a good book on PERL could have been spent
> helping the person.



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

Date: 17 Apr 1998 20:00:59 GMT
From: gbacon@cs.uah.edu (Greg Bacon)
Subject: Re: Snobby news group
Message-Id: <6h8cdr$nkk$1@info.uah.edu>

In article <6h82ft$69c$1@news.scruz.net>,
	"Database Coder" <dbcoder@juno.com> writes:
: Why is this such a snobby unhelpful news group. I have posted in many other
: news groups and always recieved polite and helpful responses. This news
: group is the exception. The amount of time you people spend asking people if
: they read the FAQ or bought a good book on PERL could have been spent
: helping the person.

It's precisely this sort of attitude that makes those of us in a
position to answer questions (believe it or not, a lot of us actually
*enjoy* helping people who are also willing to help themselves) count
the seconds until we have comp.lang.perl.moderated.  You call it
snobbery, we call it noise filtration.

When the new group is in place, I promise never again to bitch about
someone asking a FAQ on comp.lang.perl.misc. :-)

Greg
-- 
open(G,"|gzip -dc");$_=<<EOF;s/[0-9a-f]+/print G pack("h*",$&)/eg
f1b88000b620f22320303fa2d2e21584ccbcf29c84d2258084
d2ac158c84c4ece4d22d1000118a8d5491000000
EOF


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

Date: Fri, 17 Apr 1998 16:11:32 -0400
From: "Andrew F. Lee" <andrewf@cp.pathfinder.com>
Subject: Re: Snobby news group
Message-Id: <Pine.GSO.3.95.980417155952.14142A-100000@cp.pathfinder.com>

On Fri, 17 Apr 1998, Database Coder wrote:
> Why is this such a snobby unhelpful news group. I have posted in many other
> news groups and always recieved polite and helpful responses. This news
> group is the exception. The amount of time you people spend asking people if
> they read the FAQ or bought a good book on PERL could have been spent
> helping the person.
> 

Amen!

Unix gurus tend to be snobbish -- this I understand and expect.  Once I
had enough language to ask reasonable questions, they let me in the
'club'.  (BFD).  Perl is a wacky language with lotsa applications and
lotsa new users.  It would seem that some of the experienced programmers
here do not want anyone else to learn Perl.  It will be a little secret
and there will be clandestine user group meetings and a special handshake
and then no one who does know Perl will admit that they know Perl for fear
of retribution from the 'insiders' and Perl will go the way of Sanskrit or
ancient Greek and eventually some archeologist will reconstruct it from
old dead hard drives.

-------------------------------------------------------------
Andrew F. Lee                 |                              |
Software Engineer             |  parenttime.com              |
email: andrewf@pathfinder.com |  1271 Avenue of the Americas |
Phone: (212) 522-2769         |  New York, N.Y. 10020        |
-------------------------------------------------------------
        When I say, "Ignore the man behind the curtain."   
        That is because there is no man behind the curtain.



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

Date: Fri, 17 Apr 1998 16:16:22 -0400
From: "Andrew F. Lee" <andrewf@cp.pathfinder.com>
Subject: Re: Snobby news group
Message-Id: <Pine.GSO.3.95.980417161305.14142C-100000@cp.pathfinder.com>

On Fri, 17 Apr 1998, brian d foy wrote:
> In article <6h82ft$69c$1@news.scruz.net>, "Database Coder" <dbcoder@juno.com> posted:
> >Why is this such a snobby unhelpful news group. I have posted in many other
> >news groups and always recieved polite and helpful responses. This news
> >group is the exception. The amount of time you people spend asking people if
> >they read the FAQ or bought a good book on PERL could have been spent
> >helping the person.
> 
> helping people learn to answer there own questions figures heavily
> into the philosophy of a lot of people here.

I am going to teach you Irish by telling you to read a dictionary.  It's
no use, me walking you through the idiosyncracies of an ancient language.
That'd just make you a member of the welfare state.
:-)
I think you have a valid point and I think Database Coder's point is more
along the lines of "Why be rude?"  At least that is my take on it. 
-------------------------------------------------------------
Andrew F. Lee                 |                              |
Software Engineer             |  parenttime.com              |
email: andrewf@pathfinder.com |  1271 Avenue of the Americas |
Phone: (212) 522-2769         |  New York, N.Y. 10020        |
-------------------------------------------------------------
        When I say, "Ignore the man behind the curtain."   
        That is because there is no man behind the curtain.



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

Date: 17 Apr 1998 20:47:36 GMT
From: Zenin <zenin@archive.rhps.org>
Subject: Re: Snobby news group
Message-Id: <892846485.396881@thrush.omix.com>

Database Coder <dbcoder@juno.com> wrote:
: Why is this such a snobby unhelpful news group. I have posted in many other
: news groups and always recieved polite and helpful responses. This news
: group is the exception. The amount of time you people spend asking people if
: they read the FAQ or bought a good book on PERL could have been spent
: helping the person.

	Simple, because in most of the cases it would take said user half as
	much time to grep the FAQ and get the answer then it took them to
	post to the newsgroup.  This combined with the fact that most of us
	here don't feel we owe any time what so ever to help people that
	oftin haven't even tried to find the answer on there own because
	they are simply lazy.  It's the 90's, and checking the glossary or
	typing grep is too much work.

	If you pay attention, you'll notice a steady trend here.  The
	messages that show that they have at least *looked* at the docs
	and still don't understand what the problem is will generally get
	large numbers of vary polite responses.  Posts that treat the
	perl group as nothing but a free help desk even to the point of
	being to lazy to bother checking followups of there own messsages
	(all the lame "email me because I don't read this group" messages)
	get RTFM/RTFFAQ as a well deserved response.

-- 
-Zenin
 zenin@archive.rhps.org


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

Date: Fri, 17 Apr 1998 18:56:07 GMT
From: Tom Phoenix <rootbeer@teleport.com>
To: Marco Shaw <marco@nbnet.nb.ca>
Subject: Re: srand and rand fx
Message-Id: <Pine.GSO.3.96.980417114407.8799F-100000@user2.teleport.com>

On Fri, 17 Apr 1998, Marco Shaw wrote:

> I was trying to develop a secure Perl script for creating random
> passwords. 

If you'd like to build upon what others have done, check out the scripts
at this URL.

    http://cpan.perl.org/scripts/admin

> It uses the perl function 'rand', but I've noticed that there
> is a pattern to it after all. 

Yes, rand calls your system's rand (by default). And that will produce a
long, repeating sequence of pseudo-random values. 

> I don't quite understand how I can use 'srand' to increase the
> 'randomness'.  Do I just declare 'srand(time|$$), for example, and
> continue using rand in the next lines? 

srand just specifies where to start in that long, repeating sequence. If
you're using 5.004 (and if not, why not?) Perl will ensure that srand is
called with a good value before your first use of rand. But you may be
able to improve upon it with either Math::TrulyRandom or /dev/random,
which would be a good idea in this case. 

Hope this helps!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Fri, 17 Apr 1998 15:20:22 -0400
From: pudge@pobox.com (Chris Nandor)
Subject: Re: srand and rand fx
Message-Id: <pudge-1704981520380001@ppp-12.ts-1.kin.idt.net>

In article <6h7u88$981$1@garnet.nbnet.nb.ca>, "Marco Shaw"
<marco@nbnet.nb.ca> wrote:

# I was trying to develop a secure Perl script for creating random passwords.
# It uses the perl function 'rand', but I've noticed that there is a pattern
# to it after all.  I don't quite understand how I can use 'srand' to increase
# the 'randomness'.  Do I just declare 'srand(time|$$), for example, and
# continue using rand in the next lines?

If you use perl5.004 or greater (which you should!), srand() is called
automagically.  So a call to rand() will be sufficiently random already. 
Otherwise, look in perlfunc under srand, it gives a pretty good seed to
pass to srand() for you.

-- 
Chris Nandor          mailto:pudge@pobox.com         http://pudge.net/
%PGPKey=('B76E72AD',[1024,'0824 090B CE73 CA10  1FF7 7F13 8180 B6B6'])
#==               New Book:  MacPerl: Power and Ease               ==#
#==    Publishing Date: Early 1998. http://www.ptf.com/macperl/    ==#


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

Date: 17 Apr 1998 19:43:00 GMT
From: edstrom@hmsc.orst.edu (John Edstrom)
Subject: statically link modules: how to?
Message-Id: <6h8bc4$oq8$1@news.orst.edu>


I'm trying to get eperl to work on MachTen.  Its a BSD0-oid unix with
no dynamic loading.  I get the following error when building eperl:

  Failed 1/1 tests, 0.00% okay
t/07_delimiter......Can't load module Parse::ePerl, dynamic loading
not available in this perl.
  (You may need to build a new perl executable which either supports
  dynamic loading or has the Parse::ePerl module statically linked
into it.)  ...

How do I go about doing that?  I tried to hack the distribution but I
know next to nothing about configure.  When I try to build eperl into
perl I get:

make[1]: Entering directory `/bsd1/bst/perl/perl5.004_04/ext/eperl'
make[1]: *** No rule to make target `config'.  Stop.

How do I get it make the 'config' for which it so longingly yearns?


je

___
 John Edstrom | edstrom @ slugo.hmsc.orst.edu

 http://www.hmsc.orst.edu/~edstrom
 "Lurker" at BioMOO (bioinfo.weizmann.ac.il:8888)

 Hatfield Marine Science Center
 2030 S. Marine Science Drive
 Newport, Oregon     97365-5296
 wk: (541) 867 0197
 fx: (541) 867 0138


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

Date: Fri, 17 Apr 1998 11:47:41 -0700
From: Allen Choy <achoy@us.oracle.com>
Subject: Undef vs. Empty Anon Array ([]) as subroutine parameters
Message-Id: <3537A3CC.D2707571@us.oracle.com>

Hi.

I have a subroutine which expects an array reference as one of its
parameters.  In the
case where the array is empty, is it preferrable to a) pass in an undef,
or b) to
pass in an empty anon array?

I like b) since I don't have to check if it is a reference, although
I don't know what the memory implications are for passing in an empty
anonymous array
(is this a perl implementation detail?)

Just want to get some ideas and thanks in advance,

Allen



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

Date: Fri, 17 Apr 1998 19:51:28 GMT
From: John Porter <jdporter@min.net>
Subject: Re: Undef vs. Empty Anon Array ([]) as subroutine parameters
Message-Id: <3537B422.4205@min.net>

Allen Choy wrote:
> 
> Hi.
> 
> I have a subroutine which expects an array reference as one of its
> parameters.  In the
> case where the array is empty, is it preferrable to a) pass in an undef,
> or b) to
> pass in an empty anon array?

I think this really depends on the semantics of the function call.
I frequently need to distinguish between an empty container and
no container.

Think about it. If your function really *had* to handle the two
situations differently, how would it do it?  And what implications
would it raise for the caller?

hth,
John Porter


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

Date: 17 Apr 1998 18:38:53 GMT
From: klassa@aursgh.aur.alcatel.com (John Klassa)
Subject: Re: Wanna laugh?  (My First cgi.pm Script)
Message-Id: <6h87jt$o43$1@aurwww.aur.alcatel.com>

On 17 Apr 1998 10:57:41 -0400, Mark-Jason Dominus <mjd@op.net> wrote:
->Is that an `I think' or `I know'?  Because I was surprised to hear you
->say it, and when I tried it, the one you said would be slower was
->about 10% faster:
->
->% time perl -e 'print while <>' /tmp/qq  >> /dev/null
->3.66user 0.19system 0:04.30elapsed 89%CPU
->3.64user 0.14system 0:04.63elapsed 81%CPU
->3.63user 0.14system 0:04.17elapsed 90%CPU
->
->% time perl -e 'print <>' /tmp/qq  >> /dev/null
->4.03user 0.55system 0:04.98elapsed 91%CPU
->4.22user 0.39system 0:05.07elapsed 90%CPU
->4.04user 0.42system 0:04.85elapsed 91%CPU
->
->/tmp/qq is a 2.3MB file with about 63,000 lines.

Or, to do it with our friend the benchmark module:

        use Benchmark;

        timethese(250, {        
            method_1 => q{ open(INP, "/tmp/qq"); open(OUP, "/dev/null");
                           print OUP while <INP>; close OUP; close INP; },
            method_2 => q{ open(INP, "/tmp/qq"); open(OUP, "/dev/null");
                           print OUP <INP>; close OUP; close INP; }
        });

        Benchmark: timing 250 iterations of method_1, method_2...
          method_1: 27 secs (23.13 usr  3.03 sys = 26.16 cpu)
          method_2: 32 secs (25.92 usr  3.63 sys = 29.55 cpu)

-- 
John Klassa / Alcatel Telecom / Raleigh, NC, USA <><


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

Date: Fri, 17 Apr 1998 19:18:08 GMT
From: Tom Phoenix <rootbeer@teleport.com>
To: Ian Lynagh <ian@lynagh.demon.co.uk>
Subject: Re: What does "Illegal modulus zero" mean?
Message-Id: <Pine.GSO.3.96.980417121612.8799I-100000@user2.teleport.com>

On Fri, 17 Apr 1998, Ian Lynagh wrote:

> Can anyone explain the following?
> 
>   DB<6> p 9862777291 % 4294967296
> Illegal modulus zero at (eval 11) line 2, <IN> chunk 9.

Sure. As an integer, 4294967296 is the same as zero, on your machine. :-)

Some float-to-integer-related bugs, possible including this one, have been
fixed in 5.004. Hope this helps! 

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Fri, 17 Apr 1998 19:13:23 GMT
From: ced@bcstec.ca.boeing.com (Charles DeRykus)
Subject: Re: What does "Illegal modulus zero" mean?
Message-Id: <ErKo2B.5xI@news.boeing.com>

In article <4y5L2AAHs1N1EwR+@lynagh.demon.co.uk>,
Ian Lynagh  <ian@lynagh.demon.co.uk> wrote:
 > 
 > Can anyone explain the following?
 > 
 >   DB<6> p 9862777291 % 4294967296
 > Illegal modulus zero at (eval 11) line 2, <IN> chunk 9.
 > 
 > 

Perhaps a bug...  although my eyes aren't good enough to look
at the bug list anymore. 

This seems to work though:

DB<1> use Math::BigInt
 
DB<2> $i=new Math::BigInt '9862777291'
 
DB<3> $j = new Math::BigInt '4294967296'
 
DB<4> p $i % $j,"\n"
+1272842699


HTH,
--
Charles DeRykus


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

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

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