[17026] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4438 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Sep 26 21:05:33 2000

Date: Tue, 26 Sep 2000 18:05:13 -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: <970016713-v9-i4438@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Tue, 26 Sep 2000     Volume: 9 Number: 4438

Today's topics:
    Re: Can't print to filehandle while using IO::Socket (Adrian Haris)
    Re: Candidate for the top ten perl mistakes list (Ilya Zakharevich)
    Re: Candidate for the top ten perl mistakes list <emschwar@rmi.net>
    Re: Candidate for the top ten perl mistakes list (Craig Berry)
    Re: Controlling line length read by <> <nospam@david-steuber.com>
    Re: Controlling line length read by <> <nospam@david-steuber.com>
    Re: determine where visitors are "living" (Craig Berry)
    Re: floating point numbers on C vs. Perl (John Stanley)
    Re: floating point numbers on C vs. Perl (Abigail)
    Re: floating point numbers on C vs. Perl <crowj@aol.com>
    Re: floating point numbers on C vs. Perl <ronnie@catlover.com>
    Re: foreach two elements at a time? (Arthur Darren Dunham)
    Re: freeware perl script to binary... <nospam@david-steuber.com>
    Re: freeware perl script to binary... <nospam@david-steuber.com>
    Re: How can I combine regular expressions? <krahnj@acm.org>
        How secure is Perl? <Jimbo@hotmail.com>
    Re: How to get length of scalar? (Craig Berry)
    Re: How to get length of scalar? <m-w@pacbell.REMOVEME.net>
    Re: How to get length of scalar? (Craig Berry)
    Re: interpreter optimizations (Abigail)
    Re: interpreter optimizations (Michael P. Soulier)
    Re: interpreter optimizations (Abigail)
    Re: interpreter optimizations (Michael P. Soulier)
    Re: interpreter optimizations (Abigail)
    Re: interpreter optimizations (Eric Kuritzky)
        MySQL vs. mSQL <mike@sas-inc.com>
        Need test and opinion : a module to perform search on w <alian@alianwebserver.com>
    Re: Perl & SQL Server <scott@uq.edu.au>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Wed, 27 Sep 2000 01:02:15 +0200
From: adrian@duual.com (Adrian Haris)
Subject: Re: Can't print to filehandle while using IO::Socket
Message-Id: <adrian-2709000102150001@195.55.180.207>

Maybe I trimmed the code too much before posting.

in fact it does start with use strict and the -w flag is on. And as I said
I put dies everywhere, such as with the 
my $log = new IO::File ">>log.txt"; 

In fact I tried everything obvious and normal. But still those 0kb files.

I was sort of hoping someone would point out some weirdness wih the
IO::Select or Socket  modules I'm soverlooking.

Regards,
Adrian


In article <8qr3vm$fr3$1@nnrp1.deja.com>, amonotod <amonotod@netscape.net>
wrote:
> 
> OK, but let me play Abagail:
> 
> no use strict
> no -w
> 
> Now that's done with...  Would not -w have caught an error with printing
> to an invalid file handle?


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

Date: 26 Sep 2000 22:42:50 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: Candidate for the top ten perl mistakes list
Message-Id: <8qr8pa$ol7$1@charm.magnus.acs.ohio-state.edu>

[A complimentary Cc of this posting was sent to Craig Berry
<cberry@cinenet.net>],
who wrote in article <ssvqiskrlsckc1@corp.supernews.com>:
> :   - Logan, who wants to know when the ":-)" operator will be added[1].
> : 
> : [1]  And who is trying to think what its semantics would be if it
> :      were[2].
> 
> I would make it an alternative for the : in the ?: operator.  The
> semantics would be that in
> 
>   a ? b :-) c

Should not a ? b : c become

    a :-) b :-( c

?

Ilya


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

Date: 26 Sep 2000 16:55:32 -0600
From: Eric The Read <emschwar@rmi.net>
Subject: Re: Candidate for the top ten perl mistakes list
Message-Id: <xkf8zseg3vf.fsf@valdemar.cos.agilent.com>

ilya@math.ohio-state.edu (Ilya Zakharevich) writes:
> <cberry@cinenet.net>],
> wrote in article <ssvqiskrlsckc1@corp.supernews.com>:
> > I would make it an alternative for the : in the ?: operator.  The
> > semantics would be that in
> > 
> >   a ? b :-) c
> 
> Should not a ? b : c become
> 
>     a :-) b :-( c

Thus leading to two new reserved words:

if ( happiness($foo) == happy ) {
  print "Whee!\n";
} else if happiness($foo) == unhappy ) {
  print "Bah!\n"
} else { # listless, I guess
  print "feh\n";
}

-=Eric
-- 
On the one hand, everyone should LART spammers. OTOH, it's like emptying the
ocean with a thimble. On the gripping hand, it's easy to automate and better
than hiding in a sand castle as the tide rises.  -- thorfinn@tertius.net.au


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

Date: Tue, 26 Sep 2000 23:44:24 -0000
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Candidate for the top ten perl mistakes list
Message-Id: <st2d6of8oqg811@corp.supernews.com>

Ilya Zakharevich (ilya@math.ohio-state.edu) wrote:
: Should not a ? b : c become
: 
:     a :-) b :-( c

I like!

-- 
   |   Craig Berry - http://www.cinenet.net/~cberry/
 --*--  "Quidquid latine dictum sit, altum viditur."
   |


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

Date: Wed, 27 Sep 2000 00:28:22 GMT
From: David Steuber <nospam@david-steuber.com>
Subject: Re: Controlling line length read by <>
Message-Id: <m3aecufzkr.fsf@solo.david-steuber.com>

bernard.el-hagin@lido-tech.net (Bernard El-Hagin) writes:

' That's right. And that's a problem I ran into when toying with 'read'
' just now. Is there any way to read only n-bytes of each line read by <>?

Just think about it for a moment.  You are going to try and seek past
the end of the line without knowing how long the line is.  I don't
think so.  You will just have to read through the data stream and
throw away the extra stuff until you reach the end of line marker.

-- 
David Steuber | Perl apprentice, Apache/mod_perl user, and
NRA Member    | general Internet web wannabe.
ICQ# 91465842  (Using Micq 0.4.6 under Linux)

It's time to be free: http://www.harrybrowne2000.org


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

Date: Wed, 27 Sep 2000 00:31:57 GMT
From: David Steuber <nospam@david-steuber.com>
Subject: Re: Controlling line length read by <>
Message-Id: <m37l7yfzer.fsf@solo.david-steuber.com>

"Godzilla!" <godzilla@stomp.stomp.tokyo> writes:

' Constantly changing your parameters, asking a
' question and responding with argument, 
' smacks of trolling.

Sounds to me more like how a client specifies a program usually
accompanied by a lot of hand waving.

-- 
David Steuber | Perl apprentice, Apache/mod_perl user, and
NRA Member    | general Internet web wannabe.
ICQ# 91465842  (Using Micq 0.4.6 under Linux)

It's time to be free: http://www.harrybrowne2000.org


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

Date: Tue, 26 Sep 2000 22:35:01 -0000
From: cberry@cinenet.net (Craig Berry)
Subject: Re: determine where visitors are "living"
Message-Id: <st294ll1tfo4e@corp.supernews.com>

Alan J. Flavell (flavell@mail.cern.ch) wrote:
: > : But for _that_ kind of application, you couldn't care less where the
: > : user is physically located.  You're only looking for network-nearness,
: > 
: > Of course; I actually mentioned this in part of my post you didn't quote.
: 
: My apologies if you felt that my quoting had been unfair.

No worries.  Just wanted to clarify we were in agreement on that portion
all along.

: I think the point of principle that I was trying to make was something
: like this.
: 
: Somebody asked how can I get the answer to X.
: 
: They get given a method that actually give the answer to Y, which
: might be an approximate, but potentially misleading, estimate of X.

Very good summary.

: We're now discussing a situation where the answer to Y is exactly 
: the right thing, and if there was a way of getting an accurate answer
: to X it would be much less suitable for the purpose!
: 
: All's well that ends well.

One of my favorite things about usenet threads (and especially clpm
threads) is this sort of serendipitous divergence of discussion.  Taken
too far, it gets silly or severely off-topic or both pretty quickly; but
in just the right measure, it leads to unexpected discoveries.

[snip]
: Yes, I'm sorry, but there is a point of principle, as I say, (my
: example was admittedly off-topic for here, but I think serves as a
: good illustration of the point I'm trying to make) - and I can't think
: of a better place to address it.  Call it "elementary problem solving"
: if you want, but the key issue is to _ask the right question_.

Thrice amen to that!

-- 
   |   Craig Berry - http://www.cinenet.net/~cberry/
 --*--  "Quidquid latine dictum sit, altum viditur."
   |


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

Date: 26 Sep 2000 22:14:58 GMT
From: stanley@skyking.OCE.ORST.EDU (John Stanley)
Subject: Re: floating point numbers on C vs. Perl
Message-Id: <8qr752$6nu$1@news.NERO.NET>

In article <8qr63f$iqg$1@internal-news.uu.net>,
Erik van Roode  <newsposter@cthulhu.demon.nl> wrote:
>Ron Grabowski <ronnie@catlover.com> wrote:
>>  } while ( $old_sum != $sum );
>
>  When using float/double, never compare for exact equality, always
>use a range:
>   ABS (val1 - val2) > eps
>
>where eps is eg 1e-06

This is one case where you want to test for exact equality.



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

Date: 26 Sep 2000 22:18:48 GMT
From: abigail@foad.org (Abigail)
Subject: Re: floating point numbers on C vs. Perl
Message-Id: <slrn8t283p.lo9.abigail@alexandra.foad.org>

Ron Grabowski (ronnie@catlover.com) wrote on MMDLXXXIII September
MCMXCIII in <URL:news:8qr38m$ljh$1@news.cis.ohio-state.edu>:
-- This is a school related assignment ( all 10 lines of it! ). In C the
-- following code works as expected, exiting the loop after 'oldsum' and 'sum'
-- are equal to each other:
--
-- #include <stdio.h>
-- // I'm not a gifted C programmer yet...

That shows, as // isn't C, but C++ ....

-- int main ( void )
--
--  float sum = 0;
--  float oldsum = 0;
--  int counter = 0;
--     do {
--         oldsum = sum;
--         counter++;
--         sum += 1.0 / counter;
--     } while ( sum != oldsum );

This is a bad idea in C as well. Just because your compiler/platform
combination uses a certain amount of bits to represent floats doesn't
mean the next platform uses 32 as many bits.

--  printf("Sum of 1/N => %.20f, counter => %d\n", sum, counter);
--  return 0;
-- }
--
-- And the corresponding Perl code is very similiar:
--
-- use strict;
--  my $old_sum = 0.0;
--  my $sum = 0.0;
--  my $counter = 0;
--  do {
--      $old_sum = $sum;
--      $counter++;
--      $sum += 1.0 / $counter;
--  } while ( $old_sum != $sum );
--
--  print "$sum \t $old_sum\n"; # loop never terminates

No, it isn't. The corresponding C code for the above would be:

    # include <stdio.h>

    int main (int argc, char* argv []) {
        double sum, oldsum;
        int    counter;
        sum     = 0.0;
        counter = 0;
        do {
            oldsum = sum;
            sum   += 1.0 / ++ counter;
        } while (sum != oldsum);

        printf ("%.15g \t %.15g\n", sum, counter);
        return 0;
    }

which, not very surprisingly, takes a while to terminate too.

-- The Perl code does not terminate ( well it will terminate eventually but I
-- dion't want to wait a week ). The C code seems to be 'less precise' i.e. the
-- numbers are far less accurate than Perl's so the loop is able to exit after
-- about 2million interations ( roughly two or three seconds ). Perl's numbers
-- are much more exact and causing the loop to run for unacceptably long time.

Actually, both Perl and C use the same underlying datatypes. Except that
the datatype is a double, not a float.

-- Is there someway I can make Perl less precise? Some sort of pragma? I've

Making Perl less precise isn't the answer. The answer is to fix the idea
that comparing floats or doubles for (in)equality is a good idea.

Do something like:

    #!/opt/perl/bin/perl -w
    use strict;
    use constant EPSILON  =>  5E-7;
    my $old_sum = 0;
    my $sum     = 0;
    my $counter = 0;
    do {
        $old_sum = $sum;
        $sum    += 1 / ++ $counter;
    } while abs ($sum - $old_sum) > EPSILON;

    printf "Sum of 1/N => %.20f, counter => %d\n" => $sum, $counter;

    __END__

With as equivalent C code:

    # include <stdio.h>
    # include <math.h>

    # define EPSILON  (5e-7)

    int main (int argc, char* argv []) {
        double sum, oldsum;
        int    counter;
        sum     = 0.0;
        counter = 0;
        do {
            oldsum = sum;
            sum   += 1.0 / ++ counter;
        } while (fabs (sum - oldsum) > EPSILON);

        printf ("Sum of 1/N => %.20f, counter => %d\n", sum, counter);
        return 0;
    }


Running the Perl version gives:
    Sum of 1/N => 15.08587365342573104535, counter => 2000000
Running the C version gives:
    Sum of 1/N => 15.08587415342456417022, counter => 2000001


Note that the C version is *much* faster. 11.21 user time for Perl vs
0.24 user time for C on my system. That's almost 50 times faster.



Abigail

-- 
perl -we'$;=$";$;{Just=>another=>Perl=>Hacker=>}=$/;print%;'
#    A dragon waiting.
#    A spider crawling in a
#    maple tree. A dog.


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

Date: Tue, 26 Sep 2000 18:28:04 -0400
From: John Crowley <crowj@aol.com>
To: abigail@foad.org
Subject: Re: floating point numbers on C vs. Perl
Message-Id: <39D122F4.7266BCF5@aol.com>


Abigail wrote:
> 
> Ron Grabowski (ronnie@catlover.com) wrote on MMDLXXXIII September
> MCMXCIII in <URL:news:8qr38m$ljh$1@news.cis.ohio-state.edu>:
> -- This is a school related assignment ( all 10 lines of it! ). In C the
> -- following code works as expected, exiting the loop after 'oldsum' and 'sum'
> -- are equal to each other:
> --
> -- #include <stdio.h>
> -- // I'm not a gifted C programmer yet...
> 
> That shows, as // isn't C, but C++ ....
> 

careful with the sarcasm ... that form is valid in c99 ... and the
person
is in college so maybe that's what's being taught nowadays ;)


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

Date: Tue, 26 Sep 2000 23:22:53 GMT
From: Ron Grabowski <ronnie@catlover.com>
Subject: Re: floating point numbers on C vs. Perl
Message-Id: <39D12FA3.7165CBC4@catlover.com>

> careful with the sarcasm ... that form is valid in c99 ... and the
> person
> is in college so maybe that's what's being taught nowadays ;)

Abigail has a valid point. I was fully prepated take a lashing for my
bad code. I'm actually using g++ as my compiler but I failed to mention
that. I did know that // is not a valid C comment btw :)


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

Date: 26 Sep 2000 23:59:37 GMT
From: add@netcom.com (Arthur Darren Dunham)
Subject: Re: foreach two elements at a time?
Message-Id: <8qrd99$slf$1@nntp9.atl.mindspring.net>

In article <8qqsmn$bma$1@agate.berkeley.edu>,  <keith@softbook.com> wrote:
>What is the perl idiom for traversing an array two elements
>at a time?
>
>In tcl, I can say
>   foreach {a b} $list { ... }
>
>Is there some concise equivalent in Perl?

Not exactly what you're asking for, but that often signifies that the
two values are associated in some way.  If possible, I'd probably put
that data into a hash...

%data = (a, b, c, d, e, f);

You no longer have the possibility of the first variable (key) being
duplicated in the array, and you lose the "ordering" of the array
directly, but looking for one element is simplified.  And when you want
to run the list, you can do this...

#!/usr/local/bin/perl -w

%hash = (color => 'red',
         flower => 'rose',
         furniture => 'chair',
        );

while (($key, $value) = each %hash)
{
  print "key: $key, value: $value\n";
}

That *may* be more useful to you than putting pairs in a "normal" array,
but can be ignored if it's not.
--
Darren Dunham                                           ddunham@taos.com
Unix System Administrator                    Taos - The SysAdmin Company
Got some Dr Pepper?                               San Francisco Bay Area
      < Please move on, ...nothing to see here,  please disperse >


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

Date: Wed, 27 Sep 2000 00:20:31 GMT
From: David Steuber <nospam@david-steuber.com>
Subject: Re: freeware perl script to binary...
Message-Id: <m3g0mmfzxt.fsf@solo.david-steuber.com>

abigail@foad.org (Abigail) writes:

' == I'm looking for a freeware unix perl to executable file converter.
' 
' chmod, which can be found at: <ftp://ftp.gnu.org/gnu/fileutils/>, and
' runs on more Unices than you can think of.

LOL!

You are so lucky I wasn't drinking something at the time!

-- 
David Steuber | Perl apprentice, Apache/mod_perl user, and
NRA Member    | general Internet web wannabe.
ICQ# 91465842  (Using Micq 0.4.6 under Linux)

It's time to be free: http://www.harrybrowne2000.org


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

Date: Wed, 27 Sep 2000 00:24:16 GMT
From: David Steuber <nospam@david-steuber.com>
Subject: Re: freeware perl script to binary...
Message-Id: <m3d7hqfzrk.fsf@solo.david-steuber.com>

Paul Spandler <p.m.spandler@bton.ac.uk> writes:

' I find it difficult to justify spending $149 for a simple hack.

If it is a simple hack, then you can write your own.  After all, how
hard could it be to compile Perl code into an ELF executable for Linux
or a COFF executable for Windows?

-- 
David Steuber | Perl apprentice, Apache/mod_perl user, and
NRA Member    | general Internet web wannabe.
ICQ# 91465842  (Using Micq 0.4.6 under Linux)

It's time to be free: http://www.harrybrowne2000.org


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

Date: Tue, 26 Sep 2000 15:09:00 -0700
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: How can I combine regular expressions?
Message-Id: <39D11E7C.CD921FB8@acm.org>

Philip Lees wrote:
> 
> Hi. I've written a routine that transliterates Greek text into English
> (used for converting names, addresses, etc.). Sometimes, one Greek
> letter becomes two English letters (e.g. theta -> th or TH).
> 
> When one of these is at the start of a word I need to match the case
> of the second letter in the pair with that of the following character.
> These lines do the trick (for Greek letters chi, theta and psi, in
> case you're interested).
> 
> $line =~ s/\bCH([a-z]|\W)/Ch$1/g;       # adjust case of second letter
> 
> $line =~ s/\bTH([a-z]|\W)/Th$1/g;       # if followed by lower case
> $line =~ s/\bPS([a-z]|\W)/Ps$1/g;       # letter or non-word character
> 
> Is there any way I can combine these into just one glorious, Perlish,
> obfuscated expression?

How about something generic like:

$line =~ s/\b([A-Z])([A-Z])([a-z]+)\b/$1\l$2$3/g;

HTH

John


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

Date: Wed, 27 Sep 2000 01:11:16 +0100
From: xxxxx <Jimbo@hotmail.com>
Subject: How secure is Perl?
Message-Id: <dje2ts8bvuserud07b7mj95vdcb0k6d5ak@4ax.com>

Hi, 

I have to get creditcards from a form on an ecommerce site and store
them securely in a binary format within the account for FTP download.

I don't think this can be done without SSL?

Anybody have any advice or script recomendations?

Thanks,

Ian


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

Date: Tue, 26 Sep 2000 22:42:43 -0000
From: cberry@cinenet.net (Craig Berry)
Subject: Re: How to get length of scalar?
Message-Id: <st29j313d2d406@corp.supernews.com>

Samuel P (no@spam.thanks) wrote:
: How do I get the length of a string contained in a scalar variable?
: For example:
: 
: $someNum = 0123456789;

Them's some awful funny octal digits in there at the end, sir.  Are you
sure you don't mean '0123456789'?

-- 
   |   Craig Berry - http://www.cinenet.net/~cberry/
 --*--  "Quidquid latine dictum sit, altum viditur."
   |


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

Date: Tue, 26 Sep 2000 16:05:04 -0700
From: Michael Winston <m-w@pacbell.REMOVEME.net>
Subject: Re: How to get length of scalar?
Message-Id: <m-w-150BDF.16050426092000@news.pacbell.net>

> Samuel P (no@spam.thanks) wrote:
> : How do I get the length of a string contained in a scalar variable?
> : For example:
> : 
> : $someNum = 0123456789;

I've been working with perl for a whole week now, so I really just took 
this problem as a personal challenge to myself.  Here's what i came up 
with.  I'm sure there's a better way (probably simething like 
"getlength($somevar)".

$someNum='0123456789';
$count = 0;  # not necessary, but I think it's good form to declare
while (chop($someNum)) {
++$count;
};
print "$count\n";

Michael


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

Date: Tue, 26 Sep 2000 23:58:51 -0000
From: cberry@cinenet.net (Craig Berry)
Subject: Re: How to get length of scalar?
Message-Id: <st2e1rjfrh98fb@corp.supernews.com>

Michael Winston (m-w@pacbell.REMOVEME.net) wrote:
: > Samuel P (no@spam.thanks) wrote:
: > : How do I get the length of a string contained in a scalar variable?
: > : For example:
: > : $someNum = 0123456789;
: 
: I've been working with perl for a whole week now, so I really just took 
: this problem as a personal challenge to myself.  Here's what i came up 
: with.  I'm sure there's a better way (probably simething like 
: "getlength($somevar)".
: 
: $someNum='0123456789';
: $count = 0;  # not necessary, but I think it's good form to declare
: while (chop($someNum)) {
: ++$count;
: };
: print "$count\n";

If you intend that sarcastically, good one.  If not, well, it's only been
a week.  Check out the builtin 'length' function.

My personal favorite obfuscated length (which looks most mystifying when
applied to $_, as in this example) is:

  $len = () = split //;

-- 
   |   Craig Berry - http://www.cinenet.net/~cberry/
 --*--  "Quidquid latine dictum sit, altum viditur."
   |


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

Date: 26 Sep 2000 22:21:51 GMT
From: abigail@foad.org (Abigail)
Subject: Re: interpreter optimizations
Message-Id: <slrn8t289j.lo9.abigail@alexandra.foad.org>

Michael P. Soulier (msoulier@nortelnetworks.com) wrote on MMDLXXXIII
September MCMXCIII in <URL:news:8qr4e9$8pf$2@bmerhc5e.ca.nortel.com>:
?? 
??    So I haven't looked at the sourcecode myself yet, but I'm wondering if
?? anyone knows already. 
??    Does the perl interpreter do copy-on-write? So, if I pass a large array by
?? value, and don't change it, is the interpreter smart enough to not copy the
?? entire thing?


Your question doesn't make sense, as you cannot pass arrays by value.
Either you pass an array by reference (in which, just one scalar is
passed), or the array is flattened out into a list (and hence, copied).



Abigail
-- 
tie $" => A; $, = " "; $\ = "\n"; @a = ("") x 2; print map {"@a"} 1 .. 4;
sub A::TIESCALAR {bless \my $A => A} #  Yet Another silly JAPH by Abigail
sub A::FETCH     {@q = qw /Just Another Perl Hacker/ unless @q; shift @q}


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

Date: 26 Sep 2000 22:55:38 GMT
From: msoulier@nortelnetworks.com (Michael P. Soulier)
Subject: Re: interpreter optimizations
Message-Id: <8qr9ha$cap$1@bmerhc5e.ca.nortel.com>

In article <slrn8t289j.lo9.abigail@alexandra.foad.org>, Abigail wrote:

>Your question doesn't make sense, as you cannot pass arrays by value.
>Either you pass an array by reference (in which, just one scalar is
>passed), or the array is flattened out into a list (and hence, copied).

    Funny, I could have sworn it made sense. :)

    Let me restate. 

    @list1 = @list2;

    Does the interpreter completely copy @list2, or is it smart enough to only
copy-on-write?

    Mike

-- 
Michael P. Soulier, 1Z22, SKY  Tel: 613-765-4699 (ESN: 39-54699)
Optical Networks, Nortel Networks, SDE Pegasus
"...the word HACK is used as a verb to indicate a massive amount
of nerd-like effort."  -Harley Hahn, A Student's Guide to UNIX
Nortel Linux User's Group Ottawa: (internal) http://nlug.ca.nortel.com:8080


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

Date: 26 Sep 2000 23:21:59 GMT
From: abigail@foad.org (Abigail)
Subject: Re: interpreter optimizations
Message-Id: <slrn8t2bq9.lo9.abigail@alexandra.foad.org>

Michael P. Soulier (msoulier@nortelnetworks.com) wrote on MMDLXXXIII
September MCMXCIII in <URL:news:8qr9ha$cap$1@bmerhc5e.ca.nortel.com>:
-- In article <slrn8t289j.lo9.abigail@alexandra.foad.org>, Abigail wrote:
--
-- >Your question doesn't make sense, as you cannot pass arrays by value.
-- >Either you pass an array by reference (in which, just one scalar is
-- >passed), or the array is flattened out into a list (and hence, copied).
--
--     Funny, I could have sworn it made sense. :)
--
--     Let me restate. 
--
--     @list1 = @list2;
--
--     Does the interpreter completely copy @list2, or is it smart enough to onl
-- copy-on-write?


Funny, I could have sworn my explaination made sense.

Let me restate.

What is passed by value in:

    @list1 = @list2;



Abigail
-- 
perl -we 'eval {die ["Just another Perl Hacker\n"]}; print ${$@}[$#{@${@}}]'
#    The Astronomer
#    sitting. A cow near a windy
#    lane. Master Po.


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

Date: 26 Sep 2000 23:56:03 GMT
From: msoulier@nortelnetworks.com (Michael P. Soulier)
Subject: Re: interpreter optimizations
Message-Id: <8qrd2j$e96$1@bmerhc5e.ca.nortel.com>

In article <slrn8t2bq9.lo9.abigail@alexandra.foad.org>, Abigail wrote:

>Funny, I could have sworn my explaination made sense.
>
>Let me restate.
>
>What is passed by value in:
>
>    @list1 = @list2;

    Well now, that would be my question, now wouldn't it?

    If the answer is that they are expanded into lists, copied, and no such
optimization takes place, then fine. Just because you stated part of that, and
inferred the rest, doesn't mean that you were clear. If you feel my question
is beneath you, don't answer and save us both the time.

    I was simply curious about any optimizations that may or may have not been
built into the interpreter.

    Mike

-- 
Michael P. Soulier, 1Z22, SKY  Tel: 613-765-4699 (ESN: 39-54699)
Optical Networks, Nortel Networks, SDE Pegasus
"...the word HACK is used as a verb to indicate a massive amount
of nerd-like effort."  -Harley Hahn, A Student's Guide to UNIX
Nortel Linux User's Group Ottawa: (internal) http://nlug.ca.nortel.com:8080


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

Date: 27 Sep 2000 00:36:47 GMT
From: abigail@foad.org (Abigail)
Subject: Re: interpreter optimizations
Message-Id: <slrn8t2g6i.lo9.abigail@alexandra.foad.org>

Michael P. Soulier (msoulier@nortelnetworks.com) wrote on MMDLXXXIII
September MCMXCIII in <URL:news:8qrd2j$e96$1@bmerhc5e.ca.nortel.com>:
-- In article <slrn8t2bq9.lo9.abigail@alexandra.foad.org>, Abigail wrote:
--
-- >Funny, I could have sworn my explaination made sense.
-- >
-- >Let me restate.
-- >
-- >What is passed by value in:
-- >
-- >    @list1 = @list2;
--
--     Well now, that would be my question, now wouldn't it?


What part of "you cannot pass arrays by value" was unclear to you?


--     If the answer is that they are expanded into lists, copied, and no such
-- optimization takes place, then fine. Just because you stated part of that, an
-- inferred the rest, doesn't mean that you were clear. If you feel my question
-- is beneath you, don't answer and save us both the time.

I wrote:

    Either you pass an array by reference (in which, just one scalar is
    passed), or the array is flattened out into a list (and hence, copied).


Perhaps you read something between the lines; but I didn't put anything there.



Abigail
-- 
package Z;use overload'""'=>sub{$b++?Hacker:Another};
sub TIESCALAR{bless\my$y=>Z}sub FETCH{$a++?Perl:Just}
$,=$";my$x=tie+my$y=>Z;print$y,$x,$y,$x,"\n";#Abigail


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

Date: 27 Sep 2000 00:59:56 GMT
From: kuritzky@math.berkeley.edu (Eric Kuritzky)
Subject: Re: interpreter optimizations
Message-Id: <8qrgqc$fb5$1@agate.berkeley.edu>

In article <8qr9ha$cap$1@bmerhc5e.ca.nortel.com>,
Michael P. Soulier <msoulier@nortelnetworks.com> wrote:
>In article <slrn8t289j.lo9.abigail@alexandra.foad.org>, Abigail wrote:
>
>>Your question doesn't make sense, as you cannot pass arrays by value.
>>Either you pass an array by reference (in which, just one scalar is
>>passed), or the array is flattened out into a list (and hence, copied).
>
>    Funny, I could have sworn it made sense. :)
>
>    Let me restate. 
>
>    @list1 = @list2;
>
>    Does the interpreter completely copy @list2, or is it smart enough to only
>copy-on-write?

If I understand correctly, what you mean is "Is @list1 aliased to
@list2, with the right thing done if and when @list1 or @list2 are
altered?"  Also, I assume that your original question is "If I call
f(@list1), does @list1 get aliased to the local version of @_?"  I
haven't looked at the source code, but I believe that the arrays
aren't aliased.

I did the following tests on a linux system with perl 5.005_03:

[owl@nest owl]$ time perl -e '@foo=1..1e5'
1.02user 0.08system 0:01.09elapsed 100%CPU (0avgtext+0avgdata 0maxresident)k
0inputs+0outputs (222major+1611minor)pagefaults 0swaps
[owl@nest owl]$ time perl -e '@foo=1..1e5;@bar=@foo'
1.15user 0.14system 0:01.29elapsed 100%CPU (0avgtext+0avgdata 0maxresident)k
0inputs+0outputs (222major+1709minor)pagefaults 0swaps
[owl@nest owl]$ time perl -e '@foo=1..1e5;@bar=@foo;@baz=@foo'
1.44user 0.12system 0:01.56elapsed 100%CPU (0avgtext+0avgdata 0maxresident)k
0inputs+0outputs (222major+2205minor)pagefaults 0swaps

Now to show that compile time isn't a factor:

[owl@nest owl]$ time perl -e '@foo=1..10;@bar=@foo;@baz=@foo'
0.01user 0.01system 0:00.02elapsed 90%CPU (0avgtext+0avgdata 0maxresident)k
0inputs+0outputs (221major+24minor)pagefaults 0swaps

Now for the subroutine call:

[owl@nest owl]$ time perl -e 'sub f{};@foo=1..1e5;f(@foo)'
1.06user 0.08system 0:01.14elapsed 99%CPU (0avgtext+0avgdata 0maxresident)k
0inputs+0outputs (227major+1709minor)pagefaults 0swaps
[owl@nest owl]$ time perl -e 'sub f{};@foo=1..1e5;f(@foo);f(@foo)'
1.06user 0.13system 0:01.19elapsed 99%CPU (0avgtext+0avgdata 0maxresident)k
0inputs+0outputs (227major+1709minor)pagefaults 0swaps

I actually ran these tests more that once, but the results were pretty
much the same each time.

Note that the Perl 6 committee is still accepting RFC's, so if you
want Perl 6 to behave differently, go to <http://www.perl.org/perl6/>.


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

Date: Tue, 26 Sep 2000 14:54:09 -0400
From: "Michael Satkevich" <mike@sas-inc.com>
Subject: MySQL vs. mSQL
Message-Id: <8qqd1o$em4$1@murdoch.harvard.net>

Is MySQL better than mSQL?  I see more books and references to MySQL, so I
am beginning to think I should be using MySQL.

So far I have used mSQL on 2 sites.  Should I switch to MySQL?

Is another free database even better?  PostGre??

-Mike




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

Date: Wed, 27 Sep 2000 00:14:40 +0200
From: Alain BARBET <alian@alianwebserver.com>
Subject: Need test and opinion : a module to perform search on web site
Message-Id: <39D11FD0.74FA8942@alianwebserver.com>

Hi,

I've made search to find a search engine 100% in Perl with a database
engine. After I've see possiblity of module like LWP::RobotUA or
HTML::LinkExtor, I decide to make a new module:
Circa::Indexer and Circa::Search.

Features, link for download or test is here :
http://www.alianwebserver.com/circa

Source for the two modules is here :
http://www.alianwebserver.com/circa/Circa/Indexer.pm
http://www.alianwebserver.com/circa/Circa/Search.pm

Can I have your opinion about this work ? sources, features,
translation, all feedback is welcome. Help me to make a free good search
engine.

Thanks,
--
Alain & Estelle BARBET
http://www.alianwebserver.com


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

Date: Wed, 27 Sep 2000 08:47:50 +1000
From: "Scott Cowen-Sinclair" <scott@uq.edu.au>
Subject: Re: Perl & SQL Server
Message-Id: <8qr93a$dgp$1@bunyip.cc.uq.edu.au>

If you need help, feel free to mail me.  I've started writing up a final
version of my HOWTO *nix -> MSSQL and you could help check it maybe.

The best option that I have found is by using DBI::Proxy and Activestate
522.  Quite easy to get going and you can encrypt the traffic with DES with
a little fiddling.

-------------------------------
Scott Cowen-Sinclair
Software Infrastructure Group
Information Technology Services
University of Queensland
Brisbane, Australia.




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

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


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