[13920] in Perl-Users-Digest
No subject found in mail header
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Nov 10 17:48:01 1999
Date: Mon, 8 Nov 1999 13:08:18 -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: <942095298-v9-i1316@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Mon, 8 Nov 1999 Volume: 9 Number: 1316
Today's topics:
request for a perl script for merge sort blah1725@my-deja.com
Re: request for a perl script for merge sort (Craig Berry)
Re: request for a perl script for merge sort <cassell@mail.cor.epa.gov>
Re: request for a perl script for merge sort (Abigail)
Re: request for a perl script for merge sort <csaba.raduly@sophos.com>
Re: request for a perl script for merge sort blah1725@my-deja.com
Re: request for a perl script for merge sort <uri@sysarch.com>
Re: request for a perl script for merge sort (Abigail)
Re: Round off a number <skilchen@swissonline.ch>
Re: Round off a number <cassell@mail.cor.epa.gov>
search feature pooh23@my-deja.com
Re: search feature <cassell@mail.cor.epa.gov>
searching for Win32 long name to short name conversion <JTAlexander@mediaone.net>
Re: searching for Win32 long name to short name convers <methabol@hem.passagen.se>
Server Load - Perl 5 & Apache 1.3.9 <tyrelb-usenet@pangea.ca>
Re: Server Load - Perl 5 & Apache 1.3.9 (Abigail)
simulated annealing algorithm in PERL <robbins@lakewood.sps.mot.com>
Re: simulated annealing algorithm in PERL <cassell@mail.cor.epa.gov>
Re: simulated annealing algorithm in PERL <qumsieh@sympatico.ca>
sizeof($myvar) in perl? <christian_broennimann@yahoo.com>
Re: sizeof($myvar) in perl? <gellyfish@gellyfish.com>
Re: sizeof($myvar) in perl? (Abigail)
Re: sizeof($myvar) in perl? <rhomberg@ife.ee.ethz.ch>
Software package for creating dynamic web pages from mu (Phoenixl)
sorry... <mzh@cntw.com>
Re: Sort order in Perl <cassell@mail.cor.epa.gov>
sorting a large NDBM_File <Jan.Reynders@NOSPAM.QConsulting.be>
Re: sorting a large NDBM_File (Abigail)
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 05 Nov 1999 15:55:20 GMT
From: blah1725@my-deja.com
Subject: request for a perl script for merge sort
Message-Id: <7vuukm$qqk$1@nnrp1.deja.com>
Hi,
Is there a Perl package or script for merge sorting? I have a number
of files that contain lines of the form:
<timestamp> <logmessage>
I want to merge these files based on the timestamp. The timestamps
are of the form mm/dd/yyyy hh:mm:ss:mmm.
Any help in this regard is greatly appreciated.
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Fri, 05 Nov 1999 22:13:35 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: request for a perl script for merge sort
Message-Id: <s26lkf3thpc90@corp.supernews.com>
blah1725@my-deja.com wrote:
: Is there a Perl package or script for merge sorting? I have a number
: of files that contain lines of the form:
:
: <timestamp> <logmessage>
:
: I want to merge these files based on the timestamp. The timestamps
: are of the form mm/dd/yyyy hh:mm:ss:mmm.
It's unfortunate that timestamp format isn't lexically sortable. You'll
need to convert each incoming record's timestamp into a numerically
sortable time_t value using e.g. timelocal or timegm (see Time::Local).
Are each of the files sorted internally? If so, the pseudocode basically
looks like this:
open all the files
read the first line of each into separate variables
determine the sortable timestamp for each variable
do
find the earliest pending line
output it to the merged output
read the next line of input from that file and calc. its timestamp
if eof
mark that variable so it won't be used in earliness tests
while any input variables are not marked by eof
I'm picturing an array of hash references, where each hash has
'filehandle', 'line', and 'timestamp' fields. Then the separate variables
can just be the 'line' and 'timestamp' fields, and the marking step
consists simply of closing the filehandle and removing the hash ref from
the array; the terminating condition is array-empty.
Hope this is enough to spur your thoughts...
--
| Craig Berry - cberry@cinenet.net
--*-- http://www.cinenet.net/users/cberry/home.html
| "They do not preach that their God will rouse them
a little before the nuts work loose." - Kipling
------------------------------
Date: Fri, 05 Nov 1999 14:46:46 -0800
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: request for a perl script for merge sort
Message-Id: <38235E56.F9C96975@mail.cor.epa.gov>
blah1725@my-deja.com wrote:
>
> Hi,
>
> Is there a Perl package or script for merge sorting?
In the new book "Mastering Algorithms with Perl" by
Jon Orwant _et_al._ there is a whole chapter on sorting
algorithms, including substantial coverage of the mergesort.
The code is probably available at the O'Reilly site.
> I have a number
> of files that contain lines of the form:
>
> <timestamp> <logmessage>
>
> I want to merge these files based on the timestamp. The timestamps
> are of the form mm/dd/yyyy hh:mm:ss:mmm.
If this is the case, then rather than doing a true mergesort,
why don't you use the info in the files? Set up a hash which
has time as the key, and filename as the value. Walk
through the list of files and parse out the timestamps, turning
the timestamps into times [a little parsing and Time::Local
would do it for you]. Then just read the files in, in the
order given by this:
sort keys %hashname
That is two passes, but for a very large number of files may be
better than an O(N log N) algorithm.
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: 5 Nov 1999 20:26:32 -0600
From: abigail@delanet.com (Abigail)
Subject: Re: request for a perl script for merge sort
Message-Id: <slrn8274ln.dk.abigail@alexandra.delanet.com>
David Cassell (cassell@mail.cor.epa.gov) wrote on MMCCLVII September
MCMXCIII in <URL:news:38235E56.F9C96975@mail.cor.epa.gov>:
%%
%% If this is the case, then rather than doing a true mergesort,
%% why don't you use the info in the files? Set up a hash which
%% has time as the key, and filename as the value. Walk
%% through the list of files and parse out the timestamps, turning
%% the timestamps into times [a little parsing and Time::Local
%% would do it for you]. Then just read the files in, in the
%% order given by this:
%% sort keys %hashname
%%
%% That is two passes, but for a very large number of files may be
%% better than an O(N log N) algorithm.
Eh, what makes you think "sort" beats O (N log N) behaviour?
Abigail
--
perl -MTime::JulianDay -lwe'@r=reverse(M=>(0)x99=>CM=>(0)x399=>D=>(0)x99=>CD=>(
0)x299=>C=>(0)x9=>XC=>(0)x39=>L=>(0)x9=>XL=>(0)x29=>X=>IX=>0=>0=>0=>V=>IV=>0=>0
=>I=>$r=-2449231+gm_julian_day+time);do{until($r<$#r){$_.=$r[$#r];$r-=$#r}for(;
!$r[--$#r];){}}while$r;$,="\x20";print+$_=>September=>MCMXCIII=>()'
-----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
http://www.newsfeeds.com The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including Dedicated Binaries Servers ==-----
------------------------------
Date: Mon, 08 Nov 1999 10:48:02 +0000
From: Csaba Raduly <csaba.raduly@sophos.com>
Subject: Re: request for a perl script for merge sort
Message-Id: <3826AA62.A8BB7FAC@sophos.com>
blah1725@my-deja.com wrote:
>
> Hi,
>
> Is there a Perl package or script for merge sorting? I have a number
> of files that contain lines of the form:
>
> <timestamp> <logmessage>
>
> I want to merge these files based on the timestamp. The timestamps
> are of the form mm/dd/yyyy hh:mm:ss:mmm.
>
I suspect the individual logfiles are already sorted by the timestamp.
In that case what you want is a merge, NOT a mergesort.
Have you searched CPAN ?
Csaba
--
-----BEGIN GEEK CODE BLOCK-----
Version 3.1
GCS/MU d- s:- a30 C++$ UL+ P+>+++ L++ E- W+ N++ o? K? w++>$ O++$ M-
V- PS PE Y PGP- t+ 5 X++ R* tv++ b++ DI+++ D++ G- e+++ h-- r-- !y+
-----END GEEK CODE BLOCK-----
Csaba Raduly, Software Developer (OS/2), Sophos Anti-Virus
mailto:csaba.raduly@sophos.com http://www.sophos.com/
US Support +1 888 SOPHOS 9 UK Support +44 1235 559933
Life is complex, with real and imaginary parts.
------------------------------
Date: Mon, 08 Nov 1999 15:55:57 GMT
From: blah1725@my-deja.com
Subject: Re: request for a perl script for merge sort
Message-Id: <806rqb$4db$1@nnrp1.deja.com>
In article <3826AA62.A8BB7FAC@sophos.com>,
Csaba Raduly <csaba.raduly@sophos.com> wrote:
> blah1725@my-deja.com wrote:
> >
> > Hi,
> >
> > Is there a Perl package or script for merge sorting? I have a
number
> > of files that contain lines of the form:
> >
> > <timestamp> <logmessage>
> >
> > I want to merge these files based on the timestamp. The
timestamps
> > are of the form mm/dd/yyyy hh:mm:ss:mmm.
> >
> I suspect the individual logfiles are already sorted by the timestamp.
> In that case what you want is a merge, NOT a mergesort.
> Have you searched CPAN ?
Yes, the input files are already sorted on timestamp. I thought merge
sort always requires its input to sorted. That is why I said merge
sort instead of merge. Anyway, I searched the CPAN and did not find
any packages for this. For now, I am just concatenating all the
files into one and sorting it. Probably, a function called 'merge'
can be added to the language in the next release.
>
> Csaba
> --
> -----BEGIN GEEK CODE BLOCK-----
> Version 3.1
> GCS/MU d- s:- a30 C++$ UL+ P+>+++ L++ E- W+ N++ o? K? w++>$ O++$ M-
> V- PS PE Y PGP- t+ 5 X++ R* tv++ b++ DI+++ D++ G- e+++ h-- r-- !y+
> -----END GEEK CODE BLOCK-----
>
> Csaba Raduly, Software Developer (OS/2), Sophos Anti-Virus
> mailto:csaba.raduly@sophos.com http://www.sophos.com/
> US Support +1 888 SOPHOS 9 UK Support +44 1235 559933
> Life is complex, with real and imaginary parts.
>
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: 08 Nov 1999 11:18:55 -0500
From: Uri Guttman <uri@sysarch.com>
Subject: Re: request for a perl script for merge sort
Message-Id: <x7ogd50xe8.fsf@home.sysarch.com>
>>>>> "b" == blah1725 <blah1725@my-deja.com> writes:
b> Yes, the input files are already sorted on timestamp. I thought merge
b> sort always requires its input to sorted. That is why I said merge
b> sort instead of merge. Anyway, I searched the CPAN and did not find
b> any packages for this. For now, I am just concatenating all the
b> files into one and sorting it. Probably, a function called 'merge'
b> can be added to the language in the next release.
correct, merging is different though related to sorting. but there is no
easy way to define a merge function which is general purpose. a sort
requires only a sort compare sub with 2 arguments. a merge requires N
arguments and then you might as well define your own sub instead of perl
having a merge builtin. each arg would be an array ref and youwoul dhave
to process each record if it was sorted on multiple fields or needed
fields extracted. this can get non-trvial very quickly. then you have to
keep track of the current record from each list and find the lowest
(highest), output it and get the next one from that list. having this in
the perl core won't be a big win since so much of the work is done at a
perl code level (list scanning, field extractions, etc.)
anyway, more people talk about sorting than merging, but merging has its
own set of algorithms.
uri
--
Uri Guttman --------- uri@sysarch.com ---------- http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page ----------- http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net ---------- http://www.northernlight.com
------------------------------
Date: 8 Nov 1999 10:33:41 -0600
From: abigail@delanet.com (Abigail)
Subject: Re: request for a perl script for merge sort
Message-Id: <slrn82dv20.rvm.abigail@alexandra.delanet.com>
Uri Guttman (uri@sysarch.com) wrote on MMCCLX September MCMXCIII in
<URL:news:x7ogd50xe8.fsf@home.sysarch.com>:
??
?? correct, merging is different though related to sorting. but there is no
?? easy way to define a merge function which is general purpose.
#!/opt/perl/bin/perl -w
use strict;
sub interleave (&@) {
my $code = shift;
# Make a copy of the lists, as we destruct them.
my @arrays = map {[@$_]} @_;
my @result = ();
my $l = 0;
foreach my $arr (@arrays) {$l += @$arr;}
while ($l) {
my @r = $code -> (map {@$_ ? \($_ -> [0]) : undef} @arrays);
return @result unless @r;
my %done;
foreach my $r (@r) {
die "$r is not a non-negative integer\n" if $r =~ /\D/;
die "$r is out of range\n" if $r >= @arrays;
die "already did $r\n" if $done {$r};
die "list is exhausted\n" unless @{$arrays [$r]};
push @result => shift @{$arrays [$r]};
$done {$r} = 1;
$l --;
}
}
@result;
}
sub mini {
my $r = -1;
my $min = 0x7fffffff;
for (my $i = 0; $i < @_; $i ++) {
next unless defined $_ [$i];
$min = ${$_ [$r = $i]} if ${$_ [$i]} < $min;
}
$r;
}
sub msort ($@);
sub msort ($@) {
my $n = shift;
my $size = @_;
return @_ if $size <= 1;
my $l = int ($size / $n);
my $f = $size % $n;
my @chunks;
foreach (1 .. $n) {
push @chunks => [msort $n => splice @_ => 0, $l + ($f -- > 0 ? 1 : 0)];
}
interleave {mini @_} @chunks;
}
my @d = msort 5 => 10, 9, 8, 7, 6, 5, 8, 8, 8, 8, 8, 8, 4, 3, 2, 1;
print "@d\n";
__END__
Abigail
--
$" = "/"; split $, => eval join "+" => 1 .. 7;
*{"@_"} = sub {foreach (sort keys %_) {print "$_ $_{$_} "}};
%{"@_"} = %_ = (Just => another => Perl => Hacker); &{%{%_}};
-----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
http://www.newsfeeds.com The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including Dedicated Binaries Servers ==-----
------------------------------
Date: Fri, 05 Nov 1999 15:33:12 GMT
From: Samuel Kilchenmann <skilchen@swissonline.ch>
Subject: Re: Round off a number
Message-Id: <7vutb8$pqj$1@nnrp1.deja.com>
In article <3821C536.6A9375A8@entigo.com>,
steve plazony <splazony@entigo.com> wrote:
> using the round sub below, can anyone explain this:
>
> print round(113.1415, 3), "\n";
> - displays 113.141
>
> and
>
> print round(113.14151, 3), "\n";
> - displays 113.142
>
> i have read articles about Perl rounding differently
> from machine to machine.
>
This case is due to the inaccuracies involved in IEEE floating point
representations. It is not due to different rounding modes on different
machines. 113.1415 is not exactly representable in the IEEE floating
point format which is defined as:
11 bit exponent (base 2) in an excess-1023 code
1 bit sign
52 bit mantissa (binary fraction where: 1 <= mantissa < 2)
The following is stolen from the MS VC++ documentation:
Because exponents are stored in an unsigned form, the exponent is
biased by half its possible value. For type float, the bias is 127; for
type double, it is 1023. You can compute the actual exponent value by
subtracting the bias value from the exponent value.
The mantissa is stored as a binary fraction greater than or equal to 1
and less than 2. For types float and double, there is an implied
leading 1 in the mantissa in the most-significant bit position, so the
mantissas are actually 24 and 53 bits long, respectively, even though
the most-significant bit is never stored in memory.
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Fri, 05 Nov 1999 14:11:58 -0800
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Round off a number
Message-Id: <3823562E.BF60F721@mail.cor.epa.gov>
Samuel Kilchenmann wrote:
>
> In article <3822166C.A01E6C09@mail.cor.epa.gov>,
> David Cassell <cassell@mail.cor.epa.gov> wrote:
> > Frank de Bot wrote:
[snip]
> > [1] Please use the preferred answers in the FAQ to your own
> > homegrown versions.
>
> No! Don't round numbers with (s)printf unless you know what you are
> doing. (The rounding behavior of sprintf is system dependent and the
> behavior on *nixish systems is "round half to even", which is not what
> most people expect.
It's what I expect. But then I've been playing with lots of
different computers for a long time. I *prefer* a rounding
system with a known behavior, particularly when that will
match what C does. But YMMV.
> > [2] This does not appear to be IEEE-compliant - did you check?
>
> Come on! Why should a Perl programmer care about IEEE-compliancy?
Why not? We care about everything else, including spelling
errors in other programmers' posts. :-)
But I deal a lot with numerical analysis, and a biased rounding
algorithm can have icky consequences in some cases. The IEEE
may not be my favorite standards organization, but I do care
about some relevant topics.
> rather evidently Perl's duty (does Perl care about IEEE-compliancy?).
> Btw. what Frank posted, corresponds roughly to what IEEE calls "round
> to positive infinity".
A good point. Thanks for bringing it up.
> I repeat my request that one of the Perl gurus should add an idiomatic
> version of a round function to perlfaq4 which should do what most
> people expect and what is described in many places (although it doesn't
> describe the rounding behavior of sprintf): round half away from zero.
> (And i still think that such a function should be available as a Perl
> builtin.)
[snip of your code]
Nice. Would you submit those to TomC at
perlfaq-suggestions@perl.com for potential inclusion in the FAQ?
And you could wrap those up in a nice module and submit it
to CPAN. You'd be doing yourself and other programmers a
favor.
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: Fri, 05 Nov 1999 18:05:57 GMT
From: pooh23@my-deja.com
Subject: search feature
Message-Id: <7vv6a2$tk$1@nnrp1.deja.com>
Hello,
I really don't know perl that well. I'm a beginnger. I was wondering
if there was a website that free code samples. I interested in putting
a search feature on my website. Does anyone know of a website that has
free code samples for a search feature?
Thanks
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Fri, 05 Nov 1999 14:55:37 -0800
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: search feature
Message-Id: <38236069.E736F345@mail.cor.epa.gov>
pooh23@my-deja.com wrote:
>
> Hello,
> I really don't know perl that well. I'm a beginnger. I was wondering
> if there was a website that free code samples. I interested in putting
> a search feature on my website. Does anyone know of a website that has
> free code samples for a search feature?
It's not a sin to be a beginner. At least you know enough to
put a proper subject in your Subject: line, which is a good
sign.
There are dozens, if not hundreds, of websites with free Perl
code. Just about every website that has anything on CGI or
web programming has Perl code. Almost all of these have
Perl scripts which are buggy, badly-written, insecure, not
Y2K-compliant, and/or just plain ugly kludges.
I do not know of a site with a wide variety of Perl scripts,
all of which are well-written and secure. In time, Jeff
Pinyan's site will meet the 'wide variety' qualification
above.
Sorry,
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: Sat, 6 Nov 1999 16:38:52 -0500
From: "Jack Alexander" <JTAlexander@mediaone.net>
Subject: searching for Win32 long name to short name conversion
Message-Id: <Md1V3.1748$Dj6.28404@wbnws01.ne.mediaone.net>
WinNT SP6
Perl 5.004_02
I have the full pathname of an executable that I extracted from the registry
and I want to execute the binary, so I call system() with the value from the
registry. The problem is, the system() doesn't appear to take executable
with spaces. I tried quoting the string, but it still doesn't work.
Is there some package I can use to change the long file name format to the
short file name format?
thanks,
--
Jack Alexander
------------------------------
Date: Sun, 07 Nov 1999 09:56:28 +0100
From: Dan Zetterstrom <methabol@hem.passagen.se>
Subject: Re: searching for Win32 long name to short name conversion
Message-Id: <PT0lOMt65uP04JuDymngrd91rX6s@4ax.com>
On Sat, 6 Nov 1999 16:38:52 -0500, "Jack Alexander"
<JTAlexander@mediaone.net> wrotc:
>Is there some package I can use to change the long file name format to the
>short file name format?
The function Win32::GetShortPathName is probably what you are looking
for. Check the win32 pod for the standard win32 functions.
//DZ
--
Tell me your dreams and I will crush them.
------------------------------
Date: Mon, 08 Nov 1999 02:55:23 GMT
From: Tyrel <tyrelb-usenet@pangea.ca>
Subject: Server Load - Perl 5 & Apache 1.3.9
Message-Id: <38263B86.1B473985@pangea.ca>
Hi!
Is there anyway to decrease the load Perl does on a server? When I load
scripts, the load of the server seems to jump up quite rapidly (+1.00 -
+2.00).
Any suggestions would be greatly appreciated!
Thanks,
Tyrel.
------------------------------
Date: 7 Nov 1999 22:00:01 -0600
From: abigail@delanet.com (Abigail)
Subject: Re: Server Load - Perl 5 & Apache 1.3.9
Message-Id: <slrn82cisu.lh6.abigail@alexandra.delanet.com>
Tyrel (tyrelb-usenet@pangea.ca) wrote on MMCCLX September MCMXCIII in
<URL:news:38263B86.1B473985@pangea.ca>:
%%
%% Is there anyway to decrease the load Perl does on a server? When I load
%% scripts, the load of the server seems to jump up quite rapidly (+1.00 -
%% +2.00).
Well, don't do anything then if the load is 1 already.
Abigail
--
sub _'_{$_'_=~s/$a/$_/}map{$$_=$Z++}Y,a..z,A..X;*{($_::_=sprintf+q=%X==>"$A$Y".
"$b$r$T$u")=~s~0~O~g;map+_::_,U=>T=>L=>$Z;$_::_}=*_;sub _{print+/.*::(.*)/s}
*_'_=*{chr($b*$e)};*__=*{chr(1<<$e)};
_::_(r(e(k(c(a(H(__(l(r(e(P(__(r(e(h(t(o(n(a(__(t(us(J())))))))))))))))))))))))
-----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
http://www.newsfeeds.com The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including Dedicated Binaries Servers ==-----
------------------------------
Date: Fri, 05 Nov 1999 16:02:04 -0600
From: Jason Robbins <robbins@lakewood.sps.mot.com>
Subject: simulated annealing algorithm in PERL
Message-Id: <382353DC.52C7385@lakewood.sps.mot.com>
Does anyone know where I could find a simulated annealing implementation
in PERL?
--
t.i.a.,
robbins@lakewood.sps.mot.com
------------------------------
Date: Fri, 05 Nov 1999 17:26:27 -0800
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: simulated annealing algorithm in PERL
Message-Id: <382383C3.32B50B91@mail.cor.epa.gov>
Jason Robbins wrote:
>
> Does anyone know where I could find a simulated annealing implementation
> in PERL?
I haven't seen one in Perl [not 'PERL', by the way]. If you
choose to write one yourself, may I suggest you look at the
PDL module which has the computational bits done in C. Or else
read the perlxs and perlxstut pages, so you can embed the
heavy-number-crunching C code in the Perl code. If you write
one, consider submitting it to CPAN.
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: Mon, 08 Nov 1999 05:18:41 GMT
From: Ala Qumsieh <qumsieh@sympatico.ca>
Subject: Re: simulated annealing algorithm in PERL
Message-Id: <38265D9E.55577940@sympatico.ca>
Jason Robbins wrote:
>
> Does anyone know where I could find a simulated annealing implementation
> in PERL?
I believe I wrote such a function in one of my older programs.
I'll try to dig it up. If I do, I'll post it.
--Ala
------------------------------
Date: Mon, 8 Nov 1999 14:10:42 +0100
From: "Christian Broennimann" <christian_broennimann@yahoo.com>
Subject: sizeof($myvar) in perl?
Message-Id: <806i4m$pq1$1@exnews.swisscom.com>
hi
does something like sizeof($myvar) exist in perl?
if yes, does it work with arrays and hashes too?
thanks
chrstian
------------------------------
Date: 8 Nov 1999 13:27:05 GMT
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: sizeof($myvar) in perl?
Message-Id: <3826cfa9_1@newsread3.dircon.co.uk>
Christian Broennimann <christian_broennimann@yahoo.com> wrote:
> hi
> does something like sizeof($myvar) exist in perl?
> if yes, does it work with arrays and hashes too?
> thanks
Not really - however you can use length($var) to get the length of
a string (or the string representaion of a number) , scalar(@arrary) to
get the number of items in an array and scalar(keys %hash) to get the
number of key-value pairs in a hash.
/j\
--
"I managed to take her completely by surprise" - Prince Edward
------------------------------
Date: 8 Nov 1999 07:37:56 -0600
From: abigail@delanet.com (Abigail)
Subject: Re: sizeof($myvar) in perl?
Message-Id: <slrn82dkog.rem.abigail@alexandra.delanet.com>
Christian Broennimann (christian_broennimann@yahoo.com) wrote on MMCCLX
September MCMXCIII in <URL:news:806i4m$pq1$1@exnews.swisscom.com>:
??
?? does something like sizeof($myvar) exist in perl?
No. You don't need it.
?? if yes, does it work with arrays and hashes too?
No. You don't need it.
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
-----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
http://www.newsfeeds.com The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including Dedicated Binaries Servers ==-----
------------------------------
Date: Mon, 08 Nov 1999 14:48:06 +0100
From: Alex Rhomberg <rhomberg@ife.ee.ethz.ch>
Subject: Re: sizeof($myvar) in perl?
Message-Id: <3826D496.2B562B8A@ife.ee.ethz.ch>
Christian Broennimann wrote:
>
> hi
> does something like sizeof($myvar) exist in perl?
> if yes, does it work with arrays and hashes too?
the size in bytes? no. Perl uses huge structures for every bit of
information which is magically converted to the type you need:
$_ = 1;
$_ = "1".$_; #string 11
$_ += 10; #integer 11
$_ += 10.0 #double 11.0
- Alex
------------------------------
Date: 08 Nov 1999 18:06:40 GMT
From: phoenixl@aol.com (Phoenixl)
Subject: Software package for creating dynamic web pages from multiple data sources
Message-Id: <19991108130640.02719.00001850@ng-ce1.aol.com>
I've developed a software package which allows a developer to create web pages
incorporating
data from one or more data sources, e.g. database, XML objects, other web
sites, etc, or dynamically generated data. The pages can be
automatically constructed according user needs or preferences, e.g.
layout, language, disability accomodations, information requirements, etc.
More information is at:
http://members.aol.com/phoenixl/template-processor
The best place to start is with the README.html file.
Scott
------------------------------
Date: Mon, 8 Nov 1999 17:31:42 +0100
From: "michael hagberg" <mzh@cntw.com>
Subject: sorry...
Message-Id: <806ovh$7ud$1@news3.global-ip.net>
Sorry, about the style, but you did seem to treat me as an idiot with that
Word comparison. And if you must know Ive done a program in C++, and I
wanted to try out the Perl string manipulation. But when I was finished I
just couldnt get it together in one smooth package. And the Internet didnt
provide any help on the matter... You must admit it would be better here if
I could pack it all together but I guess I will have to convince my idiotic
friends about the supremecy of Perl...
Michael
------------------------------
Date: Fri, 05 Nov 1999 13:55:42 -0800
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Sort order in Perl
Message-Id: <3823525E.7E44C094@mail.cor.epa.gov>
Baris Sumengen wrote:
>
> replace ö with oe , etc.
> then sort
Baris, this isn't a good idea for several reasons.
[1] A module that does the right thing has already been cited
in this thread [the module was discussed in The Perl Journal
in a very interesting article].
[2] What happens with this sentence if you do the straightforward
substitution you have above?
"Zoey Poe sighed poetically as she slipped her toes into
her new shoes."
Also:
[3] While helping others is good, please follow Usenet etiquette
and place your post *after* the [carefully-trimmed] post
you are answering. It makes threads like this much easier.
Thanks in advance,
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: Mon, 08 Nov 1999 13:13:31 +0100
From: Jan Reynders <Jan.Reynders@NOSPAM.QConsulting.be>
Subject: sorting a large NDBM_File
Message-Id: <3826BE6B.394B@NOSPAM.QConsulting.be>
Hi,
I want to sort a huge hash, tied to a NDBM_File.
foreach $key (sort { $hash1 {$b} <=> $hash1 {$a} || $hash2 {$b} <=>
$hash2 {$a} } grep {/^$pattern/} keys %hash1) { printf "%4d %s\n",
$hash1{$key}, $key; }
worked fine until %hash1 became too large and the line gave a 'Out of
memory!' instead.
even a 'my @tmp=grep {/^$pattern/} keys %hash1' gives the same 'Out of
memory!' message.
I know Tie::IxHash can be used to keep the hash sorted but that doen't
solve my problem since I still need a grep on the keys ...
Any hints are welcome.
Jan Reynders
Jan.Reynders@QConsulting.be
------------------------------
Date: 8 Nov 1999 07:53:13 -0600
From: abigail@delanet.com (Abigail)
Subject: Re: sorting a large NDBM_File
Message-Id: <slrn82dll5.rem.abigail@alexandra.delanet.com>
Jan Reynders (Jan.Reynders@NOSPAM.QConsulting.be) wrote on MMCCLX
September MCMXCIII in <URL:news:3826BE6B.394B@NOSPAM.QConsulting.be>:
:: Hi,
::
:: I want to sort a huge hash, tied to a NDBM_File.
::
:: foreach $key (sort { $hash1 {$b} <=> $hash1 {$a} || $hash2 {$b} <=>
:: $hash2 {$a} } grep {/^$pattern/} keys %hash1) { printf "%4d %s\n",
:: $hash1{$key}, $key; }
::
:: worked fine until %hash1 became too large and the line gave a 'Out of
:: memory!' instead.
::
:: even a 'my @tmp=grep {/^$pattern/} keys %hash1' gives the same 'Out of
:: memory!' message.
::
:: I know Tie::IxHash can be used to keep the hash sorted but that doen't
:: solve my problem since I still need a grep on the keys ...
::
:: Any hints are welcome.
Well, it depends. If you are grepping most of it, you might run into
memory problems anyway.
Else, use each() and build an array:
my @array;
my $key;
while (defined ($key = each %hash1)) {
push @array => $key if $key =~ /^$pattern/;
}
foreach $key (sort {$hash1 {$b} <=> $hash1 {$a} ||
$hash2 {$b} <=> $hash2 {$b}} @array) {
printf "%4d %s\n" => $hash1 {$key}, $key;
}
You can cache the hash lookups and do a ST or a GRP, but if you're
memory bound, you probably don't want to do that.
Abigail
--
perl5.004 -wMMath::BigInt -e'$^V=Math::BigInt->new(qq]$^F$^W783$[$%9889$^F47]
.qq]$|88768$^W596577669$%$^W5$^F3364$[$^W$^F$|838747$[8889739$%$|$^F673$%$^W]
.qq]98$^F76777$=56]);$^U=substr($]=>$|=>5)*(q.25..($^W=@^V))=>do{print+chr$^V
%$^U;$^V/=$^U}while$^V!=$^W'
-----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
http://www.newsfeeds.com The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including Dedicated Binaries Servers ==-----
------------------------------
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 1316
**************************************