[18285] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 453 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Mar 9 09:05:41 2001

Date: Fri, 9 Mar 2001 06:05:13 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <984146713-v10-i453@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Fri, 9 Mar 2001     Volume: 10 Number: 453

Today's topics:
    Re: binary to decimal conversion: FAQ answer is not goo (Peter J. Acklam)
    Re: binary to decimal conversion: FAQ answer is not goo <bart.lateur@skynet.be>
    Re: binary to decimal conversion: FAQ answer is not goo (Martien Verbruggen)
    Re: building data structure with hash references <h.camp@scm.de>
    Re: Can a regex do this? <b_nospam_ill.kemp@wire2.com>
    Re: Can a regex do this? (Tad McClellan)
    Re: flock and close   with  empty read strangeness <bart.lateur@skynet.be>
    Re: GUI interface for Perl program <fayolle@enseirb.fr>
    Re: Help! apache->cgi->perl->dbi->mysql error (Jean-Rene Courtois)
        number <Waarddebon@chello.nl>
    Re: number <josef.moellers@fujitsu-siemens.com>
    Re: number <Waarddebon@chello.nl>
    Re: number (Rafael Garcia-Suarez)
    Re: number (Peter J. Acklam)
    Re: number <josef.moellers@fujitsu-siemens.com>
    Re: pack double-network-order (Martien Verbruggen)
    Re: RFC: FAQ3 update -- Using less memory (Kevin Reid)
    Re: Use PERL or Java? Which is faster? <matt@sergeant.org>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: 09 Mar 2001 13:58:03 +0100
From: jacklam@math.uio.no (Peter J. Acklam)
Subject: Re: binary to decimal conversion: FAQ answer is not good
Message-Id: <wku253m9rk.fsf@math.uio.no>

"John Lin" <johnlin@chttl.com.tw> writes:

> For binary to decimal conversion, FAQ gives some solutions:
> 
> perldoc -q convert
> 
> print ord(pack('B*','110110110110'));
> 219
> or
> print unpack('c', pack('B*','110110110110'));
> -37

How about

   unpack('N', pack('B32', substr('0' x 32 . $in, -32)))

Peter

-- 
sub int2roman{@x=split//,sprintf'%04d',shift;@r=('','I','V','X','L','C','D'
,'M');@p=([],[1],[1,1],[1,1,1],[1,2],[2],[2,1],[2,1,1],[2,1,1,1],[1,3],[3])
;join'',@r[map($_+6,@{$p[$x[0]]}),map($_+4,@{$p[$x[1]]}),map($_+2,@{$p[$x[2
]]}),map($_+0,@{$p[$x[3]]})];}print "@{[map{int2roman($_)}@ARGV]}\n";#JAPH!


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

Date: Fri, 09 Mar 2001 13:33:00 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: binary to decimal conversion: FAQ answer is not good
Message-Id: <homhatktn7t6qo5ee7mgugl1m8tni15r5s@4ax.com>

John Lin wrote:

>For binary to decimal conversion, FAQ gives some solutions:
>
>perldoc -q convert
>
>print ord(pack('B*','110110110110'));
>219
 ...
>Both give wrong answer if the binary is just a little bit longer.
>Is there any other (better) build-in function to use here?

Did you know that in recent perl's, there's an option of getting the
value of a binary nulmber, using oct()? Just start the string with '0b'.
See perldoc -f oct.

	$_ = '110110110110';
	print oct "0b$_";
-->
	3510

-- 
	Bart.


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

Date: Sat, 10 Mar 2001 00:32:24 +1100
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: binary to decimal conversion: FAQ answer is not good
Message-Id: <slrn9ahmr8.stm.mgjv@martien.heliotrope.home>

On Fri, 9 Mar 2001 18:17:18 +0800,
	John Lin <johnlin@chttl.com.tw> wrote:
> Dear all,
> 
> For binary to decimal conversion, FAQ gives some solutions:
> 
> perldoc -q convert
> 
> print ord(pack('B*','110110110110'));
> 219
> or
> print unpack('c', pack('B*','110110110110'));
> -37
> 
> Both give wrong answer if the binary is just a little bit longer.
> Is there any other (better) build-in function to use here?

The ord and 'c' template indicate that you are working with characters.
Normally, characters are 8 bytes long. You need to pick a length and
endianness you want to use in your calculations. I tend to use big
endian, because in that case the leftmost bits in the string are most
significant, and the rightmost least, and it's portable and available in
pack. Other endiannesses have odder byte orderings. In this case I'll
show you what you can do with an unsigned 32 bit integer:

$ cat foo
#!/usr/local/bin/perl -wl
use strict;

my $num = 0x370ff337;
printf "%032b %08x %u\n", $num, $num, $num;

# To convert to bitstring
my $bs1 = sprintf "%032b", $num;
my $bs2 = unpack "B32", pack "N", $num;

print "$bs1 = $bs2";

# And to convert back to an internal number:
$num = unpack "N", pack ("B32", $bs1);
printf "%032b %08x %u\n", $num, $num, $num;

# If you have a bitstring that isn't padded with zeroes on the left, you
# need to pad it out

my $bs = sprintf "%b", $num;
print $bs;
$bs = "0$bs" until length $bs >= 32;

$num = unpack "N", pack ("B32", $bs1);
printf "%032b %08x %u\n", $num, $num, $num;

$ ./foo
00110111000011111111001100110111 370ff337 923792183
00110111000011111111001100110111 = 00110111000011111111001100110111
00110111000011111111001100110111 370ff337 923792183
110111000011111111001100110111
00110111000011111111001100110111 370ff337 923792183

There are other ways of padding the string with zeroes, using substr for
example:

$bs = substr "0" x 32 . $bs, -32;

(If you have the Perl Cookbook, check page 48).

If you need signed formats, you might have to work with the native
formats, and then it becomes platform dependent what your bitstring
means, but everything else stays the same.

Note that you also could have started the program with:

my $num = 0b00110111000011111111001100110111;

Perl recognises, in 5.6.0, numerical constants specified as bitstrings
in big endian order. The fact that it's a big endian bitstring isn't
documented (at least, I can't find it in perldata or even in the Camel),
but it can't be native. The above program was ran on a little endian
system with the specified binary constant, giving the same output as
you see above.

Martien
-- 
Martien Verbruggen              | Since light travels faster than
Interactive Media Division      | sound, isn't that why some people
Commercial Dynamics Pty. Ltd.   | appear bright until you hear them
NSW, Australia                  | speak?


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

Date: Fri, 9 Mar 2001 13:53:11 +0100
From: H. Camphausen <h.camp@scm.de>
Subject: Re: building data structure with hash references
Message-Id: <98ajfc$96i$1@surz18.uni-marburg.de>

[F'up zu Daniel's account's Posting vom Thu, 08 Mar 2001 20:48:11 GMT]

> I want to put this data into a hash data structure. Using the above
> example, I want to create the following hash:
> 
>    home
>     |-> foo
>          |-> test
> 
> This problem is complicated by the fact that my data is not of a fixed
> depth. For example, 

<hint>
Maybe Data::Iterator could be kind of useful for you. The module was 
originally written to iterate over deeply nested structures (LoL, LoH 
etc.), but can as well be used to build those, providing stringified 
"data paths", either given in perl-like syntax (e.g. 
"{foo}{bar}[2]{baz}") or in a bit simplified way (e.g. "#foo#bar#2#baz").

You can get the module from CPAN:

http://cpan.valueclick.com/authors/id/H/HC/HCAMP/Data-Iterator-0.021.zip

</hint>


mfg, Hartmut

-- 
CREAGEN Computerkram     Fon: 06422/850527
Hartmut Camphausen       Fax: 06422/850528
Am kleinen Born 1        E-Mail: h.camp@creagen.de
35287 Amöneburg          WWW: http://www.creagen.de


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

Date: Fri, 9 Mar 2001 12:41:13 -0000
From: "W K" <b_nospam_ill.kemp@wire2.com>
Subject: Re: Can a regex do this?
Message-Id: <984141848.20332.0.nnrp-13.c3ad6974@news.demon.co.uk>

>>>>>>Perfect use for tr///
>>>>>>


Have I missed something?
What is wrong with using tr?
(is this only because Mr. B. Blah isn't  using perl?)

>
>Are you? I responded to him. He used perl, not a pure regex.
>


I am shocked. People on this newsgroup using perl. whatever next.




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

Date: Fri, 9 Mar 2001 07:02:18 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Can a regex do this?
Message-Id: <slrn9ahhia.guc.tadmc@tadmc26.august.net>

blahblah <blah@blah.com> wrote:
>On Fri, 09 Mar 2001 04:20:43 GMT, tadmc@augustmail.com (Tad McClellan)
>wrote:
>>blahblah <blah@blah.com> wrote:
>>>On 9 Mar 2001 03:33:30 GMT, sholden@pgrad.cs.usyd.edu.au (Sam Holden)
>>>wrote:
>>>>On Thu, 08 Mar 2001 21:26:06 -0600, blahblah <blah@blah.com> wrote:
>>>>>On Fri, 9 Mar 2001 12:40:28 +0930, "Wyzelli" <wyzelli@yahoo.com>
>>>>>wrote:
>>>>>
>>>>>>"blahblah" <blah@blah.com> wrote in message
>>>>>>news:2dggatgkelcs2t0ub7fdst8s9jgrup4c8m@4ax.com...
>>>>>>> I am looking for a regex that will do two replacements on the same
>>>>>>> line. For example:
>>>>>>>
>>>>>>> $test =~ s/1/a/g;
>>>>>>> $test =~ s/2/b/g;
>>>>>>> $test =~ s/3/c/g;

>>>>>>> Can this be done on the same line?

>>>is there no way to do it all in one
>>>line? 
>>
>>Yes there is a way. Wyzelli has already shown you how. Are you
>>reading this thread?
>
>Are you? I responded to him. He used perl, not a pure regex.


Of course he used Perl you silly goose! This is the Perl
newsgroup. If you don't want Perl then don't go to the
Perl newsgroup.


>>In the spirit of TMTOWTDI, here is another one-line way:
>>
>>   $test =~ s/1/a/g; $test =~ s/2/b/g; $test =~ s/3/c/g;
>
>Again, that's not one line of code.


Yes it is.

A "line" ends with a newline. The code above ends with a newline,
therefore it is a line. There is only one such line of code.
Just what you asked for.

If you wanted one *statement*, then you should have asked for
one statement. (but you got one of those already too)

Go away anonymous troll.


*plonk*


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: Fri, 09 Mar 2001 13:21:17 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: flock and close   with  empty read strangeness
Message-Id: <a3mhatgcqbeah6bkti3msnn12vb2tlj6o0@4ax.com>

Abigail wrote:

>There's still no compromise, because you let *all* of the processes
>requesting a shared lock wait, even while they could have continued.

That "compromise" is that in order for processes that want to write not
having to wait forever, other processes that could have continued now do
have to wait. It's an "acceptable delay" for everybody, not a "no delay
in most cases, but a very likely very long delay in other, pretty common
situations".

-- 
	Bart.


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

Date: Fri, 9 Mar 2001 12:55:08 +0100
From: "Pierre-Alain Fayolle" <fayolle@enseirb.fr>
Subject: Re: GUI interface for Perl program
Message-Id: <98agbh$slk$1@news.u-bordeaux.fr>

I suggest you these two url:
       http://www.pconline.com/~erc/perltk.htm
       http://www.perl.com/pub/1999/10/perltk/
       http://www.lns.cornell.edu/~pvhp/ptk/doc/

Pierre A. Fayolle


>Thanks. I will try Tk. Maybe I will like it. I gave up with >Win32::GUI
>when I get strange results.
>
>Pozdrowienia
>Mirek Rewak





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

Date: Fri, 9 Mar 2001 12:49:41 +0000 (UTC)
From: jr@news.fr.clara.net (Jean-Rene Courtois)
Subject: Re: Help! apache->cgi->perl->dbi->mysql error
Message-Id: <slrn9aho25.e9v.jr@jrc.admin.kapt.com>

DBA+ <oracle@zonai.com> a écrit :
> I made a perl script to query some table in an MySQL database using the
> DBI and it runs without a problem from the shell as root      BUT
> when I try to execute it from the browser it aborts with an "MySQL could
> not connect thru socket '/var/local/mysql/mysql.sock'". I suspect that
> some environment variable is missing in this process because I get the
> same error when I try to execute the script logged as a regular user.
> Any help will be greatly super-appreciated.

I think it is more a problem with Mysql than with Perl...


-- 
jrcourtois@webmails.com
courtois@fiifo.u-psud.fr


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

Date: Fri, 09 Mar 2001 12:34:55 GMT
From: "Waarddebon" <Waarddebon@chello.nl>
Subject: number
Message-Id: <P54q6.1909076$%C1.24675043@Flipper>

In my script i've got some variables with .00 behind it.
for example $xx="55.00"

Which line do i need so that $xx will contain 55 (so without the .00)
Thanks in advance




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

Date: Fri, 09 Mar 2001 13:45:41 +0100
From: Josef Moellers <josef.moellers@fujitsu-siemens.com>
Subject: Re: number
Message-Id: <3AA8D075.CD89AFFD@fujitsu-siemens.com>

Waarddebon wrote:
> =

> In my script i've got some variables with .00 behind it.
> for example $xx=3D"55.00"
> =

> Which line do i need so that $xx will contain 55 (so without the .00)

$xx =3D "55";

-- =

Josef M=F6llers (Pinguinpfleger bei FSC)
	If failure had no penalty success would not be a prize
						-- T.  Pratchett


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

Date: Fri, 09 Mar 2001 13:11:17 GMT
From: "Waarddebon" <Waarddebon@chello.nl>
Subject: Re: number
Message-Id: <VD4q6.1909288$%C1.24685312@Flipper>


I need a line which takes care of it...
>
> In my script i've got some variables with .00 behind it.
> for example $xx="55.00"
>
> Which line do i need so that $xx will contain 55 (so without the .00)

$xx = "55";

--
Josef Möllers (Pinguinpfleger bei FSC)
If failure had no penalty success would not be a prize
-- T.  Pratchett




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

Date: Fri, 09 Mar 2001 13:24:22 GMT
From: rgarciasuarez@free.fr (Rafael Garcia-Suarez)
Subject: Re: number
Message-Id: <slrn9ahmbs.443.rgarciasuarez@rafael.kazibao.net>

Waarddebon wrote in comp.lang.perl.misc:
> In my script i've got some variables with .00 behind it.
> for example $xx="55.00"
> 
> Which line do i need so that $xx will contain 55 (so without the .00)

Several solutions :

  $xx =~ s/\.00$//;

  $xx = substr($xx,0,2);

  $xx = sprintf("%d",$xx);

  $xx =~ /^(\d+)/; $xx = $1;

  etc. (ad nauseam.)

(Well, you haven't been very clear in your problem description).

-- 
Rafael Garcia-Suarez / http://rgarciasuarez.free.fr/


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

Date: 09 Mar 2001 14:36:30 +0100
From: jacklam@math.uio.no (Peter J. Acklam)
Subject: Re: number
Message-Id: <wkpufrkqsh.fsf@math.uio.no>

Josef Moellers <josef.moellers@fujitsu-siemens.com> writes:

> Waarddebon wrote:
> > 
> > In my script i've got some variables with .00 behind it.
> > for example $xx="55.00"
> > 
> > Which line do i need so that $xx will contain 55 (so without the .00)
> 
> $xx = "55";

Why the quotation marks?

A simple way is to use numeric context

   $x += 0;

Peter

-- 
sub int2roman{@x=split//,sprintf'%04d',shift;@r=('','I','V','X','L','C','D'
,'M');@p=([],[1],[1,1],[1,1,1],[1,2],[2],[2,1],[2,1,1],[2,1,1,1],[1,3],[3])
;join'',@r[map($_+6,@{$p[$x[0]]}),map($_+4,@{$p[$x[1]]}),map($_+2,@{$p[$x[2
]]}),map($_+0,@{$p[$x[3]]})];}print "@{[map{int2roman($_)}@ARGV]}\n";#JAPH!


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

Date: Fri, 09 Mar 2001 14:49:48 +0100
From: Josef Moellers <josef.moellers@fujitsu-siemens.com>
Subject: Re: number
Message-Id: <3AA8DF7C.FA72E6B8@fujitsu-siemens.com>

"Peter J. Acklam" wrote:
> =

> Josef Moellers <josef.moellers@fujitsu-siemens.com> writes:
> =

> > Waarddebon wrote:
> > >
> > > In my script i've got some variables with .00 behind it.
> > > for example $xx=3D"55.00"
> > >
> > > Which line do i need so that $xx will contain 55 (so without the .0=
0)
> >
> > $xx =3D "55";
> =

> Why the quotation marks?

Look at the OP's question! It had quotation marks, too!

Josef
-- =

Josef M=F6llers (Pinguinpfleger bei FSC)
	If failure had no penalty success would not be a prize
						-- T.  Pratchett


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

Date: Fri, 9 Mar 2001 22:53:33 +1100
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: pack double-network-order
Message-Id: <slrn9ahh1s.rvg.mgjv@martien.heliotrope.home>

On Thu, 08 Mar 2001 16:55:01 +0100,
	Daniel Heiserer <daniel.heiserer@bmw.de> wrote:
> Hi,
> I looked at the template list for pack and I didn't find
> how to pack a double using the network-order , which is IEEE-be.
> 
> Does anybody how this can be achieved?
> Would it work if I pack native "double" format first, then unpack 
> to native long, which means twice as many values, and the pack
> again using long in "network/ieee-be" order?
> 

Here's a C solution implementing IEEE 754 for doubles. It's wrapped in
some Perl macros and made available to Perl with Inline::C. if you need
to use IEEE-be for compatibility with another applicaiton, you'll have
to adapt this. I don't have IEEE-be spec, but I believe it's the same as
RFC 1014, right? That RFC quotes IEEE 754-1985 as a source for floats
and doubles, so i suspect this is what you want.

Anyway, the following gives you two perl function, to_ieee754 and 
from_ieee_754. I have only implemented doubles, since that's what Perl
has internally, and you seem to indicate that that's what you need. It's
not too hard to implement other types, and have the perl callable
functions work out what to do. to_ieee754 takes a double, and you will
get a warning if you supply anything non-numeric. from_ieee754 takes an
8 byte string as generated by to_ieee754, and returns the double value
of that string. It will return undef if you pass it something else than
a 8 byte string.

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

use Inline C => "DATA";

my $aaa = to_ieee754(1.2e-45);
my $d = from_ieee754($aaa);
print "$d\n";

$aaa = "foo";
$d = from_ieee754($aaa);
print $d ? "$d\n" : "undef\n";

__DATA__
__C__

/* 
 * Code adapted from code in chapter 6 of 'C Unleashed', 
 * written by Steve Summit
 */
#include <stdlib.h>
#include <string.h>
#include <math.h>

static void
to_ieee754_d(double d, unsigned char buf[8])
{
    double        mantf, mantf2;
    unsigned long mantl, mantl2, mantl2hi;
    long          mantlhi;
    int           e, s = 0, shift = 53, add = 0;

    mantf = frexp(d, &e);
    if(mantf != 0)
        e += 1022;
    if(e <= 0)				/* denormalized */
    {
        shift += e-1;
        e = 0;
    }
    if(mantf < 0)
    {
        s = 1;
        mantf = -mantf;
    }
    mantf2 = ldexp(mantf, shift-32+1);
    mantlhi = (long)mantf2;
    mantl = (unsigned long int)ldexp(mantf2 - mantlhi, 32);
    if(mantl & 1)
        add = 1;
    mantl >>= 1;
    if(mantlhi & 1)
        mantl |= 1L<<31;
    mantlhi >>= 1;
    if(add)
    {
        mantl++;
        if(mantl == 0)
            mantlhi++;
    }
    mantl2 = mantl;
    mantl2hi = mantlhi & ~(1L << (52-32));	/* zap implicit leading 1 */
    mantl2hi |= ((unsigned long)s << (63-32)) | 
                ((unsigned long)(e & 0x7ff) << (52-32));
    buf[0] = (unsigned char)(mantl2 & 0xff);
    buf[1] = (unsigned char)((mantl2 >> 8) & 0xff);
    buf[2] = (unsigned char)((mantl2 >> 16) & 0xff);
    buf[3] = (unsigned char)((mantl2 >> 24) & 0xff);
    buf[4] = (unsigned char)(mantl2hi & 0xff);
    buf[5] = (unsigned char)((mantl2hi >> (40-32)) & 0xff);
    buf[6] = (unsigned char)((mantl2hi >> (48-32)) & 0xff);
    buf[7] = (unsigned char)((mantl2hi >> (56-32)) & 0xff);
}

static double
from_ieee754_d(unsigned char buf[8])
{
    unsigned long mant, manthi;
    int e, s, shift;
    double d;

    mant    = buf[0];
    mant   |= (unsigned long)buf[1] << 8;
    mant   |= (unsigned long)buf[2] << 16;
    mant   |= (unsigned long)buf[3] << 24;
    manthi  = buf[4];
    manthi |= (unsigned long)buf[5] << (40-32);
    manthi |= (unsigned long)(buf[6] & 0x0f) << (48-32);

    e = ((buf[7] & 0x7f) << 4) | ((buf[6] >> 4) & 0x0f);
    s = buf[7] & 0x80;

    shift = e - 1023 - 52;
    if(e == 0)
        shift++;                        /* denormalized */
    else	
        manthi |= (1L << (52-32));      /* restore implicit leading 1 */

    d = ldexp(manthi, shift+32) + ldexp(mant, shift);

    if(s)
        return -d;
    else
        return d;
}

/* Perl callable functions */

SV *
to_ieee754(double d)
{
    char buf[8];
    to_ieee754_d(d, buf);
    return newSVpv(buf, 8);
}

SV *
from_ieee754(char *buf)
{
    double d;
    if (strlen(buf) != 8)
        return &PL_sv_undef;
    d = from_ieee754_d(buf);
    return newSVnv(d);
}


I just _love_ Inline::C.

Martien
-- 
Martien Verbruggen              | 
Interactive Media Division      | In a world without fences, who needs
Commercial Dynamics Pty. Ltd.   | Gates?
NSW, Australia                  | 


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

Date: Fri, 9 Mar 2001 09:02:28 -0500
From: kpreid@attglobal.net (Kevin Reid)
Subject: Re: RFC: FAQ3 update -- Using less memory
Message-Id: <1epx23y.fv2few1et54xgN%kpreid@attglobal.net>

Dan Sugalski <dan@tuatha.sidhe.org> wrote:

> Bart Lateur <bart.lateur@skynet.be> wrote:
> > Heh? Maybe you're talking about the LWP tool, I'm not familiar with
> > those, but on an ordinary Mac, applications NEVER request more memory
> > from the OS, and they NEVER give anything back either, during their
> > life. All apps have a memory preference set, and they get a certain
> > amount of memory at startup, and that they have to get by with for the
> > rest of their life. All memory allocations and frees are within the
> > scope of this chunk. The Finder (OS with GUI) is the only exception to
> > this rule.
> 
> I'm pretty sure that this isn't the case, and you can ask for memory
> that's not in your allocated memory chunk--whether you get it or not
> is an entirely different question, but you can ask.

Right, but MacPerl doesn't use this method.

> Regardless, the
> Mac keeps track of how much of the allocated memory space for an app
> is actually used. If you don't use a piece of the space, it
> won't take up RAM (or swap, IIRC, which I might not) leaving it free for
> other apps.

Not true. Applications take up their defined chunk of the total
availabile memory, whether or not they're using it.

               -- SMTYEWTK* on Mac OS memory allocation --

An advantage of this system is that an application with a known limit on
memory usage will never run out of memory.

Similarly, an application can't use more than its defined memory
segment, unless it's requesting "temporary memory".

Temporary memory is allocated in the system heap, which is at the "low"
end of memory, whereas application partitions are allocated at the
"high" end, in the largest contiguous section of memory.

There is always a total amount of real/virtual memory "existent", which
cannot change without a reboot.

-- 
 Kevin Reid: |    Macintosh:      
  "I'm me."  | Think different.

* Somewhat More Than...


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

Date: Fri, 09 Mar 2001 12:30:20 +0000
From: Matt Sergeant <matt@sergeant.org>
Subject: Re: Use PERL or Java? Which is faster?
Message-Id: <3AA8CCDC.6451AD1A@sergeant.org>

brian d foy wrote:
> 
> In article <3AA75788.3CF1C6D2@bigfoot.com>, Thorbjørn Ravn Andersen
> <thunderbear@bigfoot.com> wrote:
> 
> > Daniel Berger wrote:
> >
> > > As for speed, I have *yet* to see a Java app that was as fast or faster than Perl/Tk,
> > > or Perl in general for that matter.
> >
> > I parse XML with Java because it is a _lot_ faster than with Perl.
> 
> do you have some benchmarks for whatever you were doing?  it would
> be interesting to see the relative speeds. :)

There were some on XML.com a long time ago done by Clark Cooper (XML::Parser
author). Basically it went something like:

Raw expat:    1 # index
Java (IBM):   5
Java (Sun):   6
XML::Parser: 20
PyExpat:     21

This is from memory, mind you. I'm sure you could probably search XML.com to
find it (I'm being lazy :-)

The problem, like Thorbjorn puts it, is the callbacks to perl are slow.

Orchard changes this landscape somewhat, but only if you do the tree
building in Orchard/MoC, rather than Perl (you can't speed up the callbacks
unless you somehow made Orchard nodes first class objects in Perl).

Personally right now I use Storable as a cache to get around the speed
problems.

-- 
<Matt/>

    /||    ** Founder and CTO  **  **   http://axkit.com/     **
   //||    **  AxKit.com Ltd   **  ** XML Application Serving **
  // ||    ** http://axkit.org **  ** XSLT, XPathScript, XSP  **
 // \\| // ** mod_perl news and resources: http://take23.org  **
     \\//
     //\\
    //  \\


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

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 V10 Issue 453
**************************************


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