[30332] in Perl-Users-Digest
Perl-Users Digest, Issue: 1575 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat May 24 18:09:46 2008
Date: Sat, 24 May 2008 15:09:08 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Sat, 24 May 2008 Volume: 11 Number: 1575
Today's topics:
Re: Accessing individual bits in a number <hjp-usenet2@hjp.at>
Re: creating directory before a module is loaded. <pue@gmx.net>
Re: Delay in program execution <tadmc@seesig.invalid>
Re: Delay in program execution <bill@ts1000.us>
Re: Delay in program execution <1usa@llenroc.ude.invalid>
Re: Delay in program execution <hjp-usenet2@hjp.at>
Re: FAQ 5.18 How can I open a file with a leading ">" o <tadmc@seesig.invalid>
Re: FAQ 5.18 How can I open a file with a leading ">" o <jurgenex@hotmail.com>
Re: maintaining order in a hash (without Tie::IxHash) <ben@morrow.me.uk>
Re: Out of memory! Yet ... <hjp-usenet2@hjp.at>
Re: Out of memory! Yet ... <hjp-usenet2@hjp.at>
Re: Out of memory! Yet ... sln@netherlands.co
Re: Perl software? <hjp-usenet2@hjp.at>
Re: Perl vs. Php <tadmc@seesig.invalid>
Re: Range of number <abigail@abigail.be>
Re: reference/alias in perl vs reference/alias in C++ <tadmc@seesig.invalid>
Re: Regex for password checking <tadmc@seesig.invalid>
Re: Using a buffer with HTTP::Response? <rvtol+news@isolution.nl>
Re: Using a buffer with HTTP::Response? <rvtol+news@isolution.nl>
Yet another interface to SWI-Prolog in mod_perl <yingun@gmail.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sat, 24 May 2008 17:45:53 +0200
From: "Peter J. Holzer" <hjp-usenet2@hjp.at>
Subject: Re: Accessing individual bits in a number
Message-Id: <slrng3ge1h.p97.hjp-usenet2@hrunkner.hjp.at>
On 2008-05-19 20:07, googler <pinaki_m77@yahoo.com> wrote:
> I need to find the Gray code equivalent of a given number. The number
> should be entered as an input (in decimal) and the output should be
> the Gray code equivalent (a string of 1s and 0s). For this
> computation, I need to perform XOR operations between the bits of the
> input number. Is there a way by which individual bits in a number can
> be accessed in Perl?
It seems you already know this:
> $binary[$i] = $x & 0x0001;
You use &
> $x = $x >> 1;
and >>
> $gray[$i] = $binary[$i+1] ^ $binary[$i];
and ^
what more do you need?
(well, ~, | and <<, of course, but I guess you know about them, too)
hp
------------------------------
Date: Sat, 24 May 2008 22:03:14 +0200
From: =?ISO-8859-1?Q?Andreas_P=FCrzer?= <pue@gmx.net>
Subject: Re: creating directory before a module is loaded.
Message-Id: <69raa3F3424fnU1@mid.individual.net>
Jim Gibson schrieb:
> In article <69o0sjF30rjvvU1@mid.individual.net>, Andreas Pürzer
> <pue@gmx.net> wrote:
>
>> gsa schrieb:
>> example.pm in turn uses
>>> the CPAN module Inline.pm.
>
>> What happens if you put the BEGIN into pvalueCalculation.pm, where it is
>> actually needed?
>
> When the Perl interpreter encounters the first 'use pvalueCalculation;'
> statement, it will find and process pvalueCalculation.pm. When it
> encounters the BEGIN statement in that file, it will process and
> execute its contents.
>
Yes, of course, but that's not the point i was trying to make:
The OP had the BEGIN in the script using pvalueCalculation.pm, not the
Module itself!
So let me rephrase my suggestion in the hope of making it clearer this time:
Why is the BEGIN, that is setting up the environment for the Module, not
in the Module itself?
Just like you said, once the interpreter finds the BEGIN, it will
execute its contents, and from then on, the module will have it all set
up. No more hassle with the order of use and BEGIN. ;)
Greetings,
Andreas Pürzer
--
Have Fun,
and if you can't have fun,
have someone else's fun.
The Beautiful South
------------------------------
Date: Sat, 24 May 2008 10:22:03 -0500
From: Tad J McClellan <tadmc@seesig.invalid>
Subject: Re: Delay in program execution
Message-Id: <slrng3gckr.2n2.tadmc@tadmc30.sbcglobal.net>
Bill H <bill@ts1000.us> wrote:
> I know (or believe strongly) perl
Or maybe you simply read the docs about how perl executes?
> compiles the source for running the program,
perldoc perlrun
...
After locating your program, Perl compiles the entire program to an
internal form.
--
Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"
------------------------------
Date: Sat, 24 May 2008 12:38:26 -0700 (PDT)
From: Bill H <bill@ts1000.us>
Subject: Re: Delay in program execution
Message-Id: <54bcc2bb-97db-42f6-a51f-c560083dfa8e@2g2000hsn.googlegroups.com>
On May 24, 11:22=A0am, Tad J McClellan <ta...@seesig.invalid> wrote:
> Bill H <b...@ts1000.us> wrote:
> > I know (or believe strongly) perl
>
> Or maybe you simply read the docs about how perl executes?
>
> > compiles the source for running the program,
>
> =A0 =A0perldoc perlrun
>
> =A0 =A0 =A0 =A0...
> =A0 =A0 =A0 =A0After locating your program, Perl compiles the entire progr=
am to an
> =A0 =A0 =A0 =A0internal form.
>
> --
> Tad McClellan
> email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"
Thats what I thought - but does it keep the compiled version to use
over and over again till I change the code as it appears to do? If so,
where? If not, then why the delay after I change code, just that 1st
time, then it runs fast again?
Bill H
------------------------------
Date: Sat, 24 May 2008 20:45:04 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: Delay in program execution
Message-Id: <Xns9AA8AA66282ECasu1cornelledu@127.0.0.1>
Bill H <bill@ts1000.us> wrote in
news:54bcc2bb-97db-42f6-a51f-c560083dfa8e@2g2000hsn.googlegroups.com:
[ do *NOT* quote sigs ]
> On May 24, 11:22 am, Tad J McClellan <ta...@seesig.invalid> wrote:
>> Bill H <b...@ts1000.us> wrote:
>> > I know (or believe strongly) perl
>>
>> Or maybe you simply read the docs about how perl executes?
>>
>> > compiles the source for running the program,
>>
>> perldoc perlrun
>>
>> ...
>> After locating your program, Perl compiles the entire
>> program to an internal form.
...
> Thats what I thought - but does it keep the compiled version to use
> over and over again till I change the code as it appears to do?
No. (You specified that mod_perl is not involved).
> If not, then why the delay after I change code, just that 1st
> time, then it runs fast again?
Look at line 42.
Sinan
>
> Bill H
>
--
A. Sinan Unur <1usa@llenroc.ude.invalid>
(remove .invalid and reverse each component for email address)
comp.lang.perl.misc guidelines on the WWW:
http://www.rehabitation.com/clpmisc/
------------------------------
Date: Sat, 24 May 2008 23:38:14 +0200
From: "Peter J. Holzer" <hjp-usenet2@hjp.at>
Subject: Re: Delay in program execution
Message-Id: <slrng3h2m8.tj4.hjp-usenet2@hrunkner.hjp.at>
On 2008-05-24 19:38, Bill H <bill@ts1000.us> wrote:
> On May 24, 11:22 am, Tad J McClellan <ta...@seesig.invalid> wrote:
>> Bill H <b...@ts1000.us> wrote:
>> > I know (or believe strongly) perl
>>
>> Or maybe you simply read the docs about how perl executes?
>>
>> > compiles the source for running the program,
>>
>> perldoc perlrun
>>
>> ...
>> After locating your program, Perl compiles the entire program to an
>> internal form.
>
> Thats what I thought - but does it keep the compiled version to use
> over and over again till I change the code as it appears to do?
No. The soure is compiled each time the program is started (and it
shouldn't take "3 or 4 seconds" unless it is really huge).
You wrote that you don't use mod_perl but you didn't write what you do
use and how you "post" a module. If your perl program is started for
each request (as CGI does), then I don't see any reason for the
bevaviour you observe. But if your perl program runs persistently in the
background (maybe via FastCGI or PPerl) and needs to be restarted after
posting the module, than that's possible.
hp
------------------------------
Date: Sat, 24 May 2008 09:15:45 -0500
From: Tad J McClellan <tadmc@seesig.invalid>
Subject: Re: FAQ 5.18 How can I open a file with a leading ">" or trailing blanks?
Message-Id: <slrng3g8oh.2n2.tadmc@tadmc30.sbcglobal.net>
Bill H <bill@ts1000.us> wrote:
[ attribution missing: The Perl FAQ server wrote: ]
>> Unless you have a particular reason to use the two argument form you
>> should use the three argument form of open() which does not treat any
>> characters in the filename as special.
> Other than the reasons given above, is there any effeciency or speed
> benefits to using:
A generally applicable response to such a question is:
If what follows is a difference in algorithms
discussion proceeds
else
it doesn' matter enough to consider
> open FILE, ">", "file";
>
> instead of:
>
> open(FILE,">file");
In general, minor tweeks to syntax is not the "low hanging fruit"
when it comes to improving the execution speed of programs.
(fixing algorithms is.)
If you really want to know, then
use Benchmark;
and find out.
> does the former skip a parser step that could could increase the speed
> of a program (or its compilation)?
In this particular case, any execution time saved will be swamped
by the time required for I/O. (it requires disk access to open a file.)
If it takes 1000 $timeunits to open a file it is likely to take
2 $timeunits to compile/execute the call that opens a file.
If one syntax takes 1002 $timeunits and the other takes only 1001
$timeunits, then spending 100,000,000 $timeunits thinking about
the difference is not an effective use of programmer time.
--
Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"
------------------------------
Date: Sat, 24 May 2008 15:18:47 GMT
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: FAQ 5.18 How can I open a file with a leading ">" or trailing blanks?
Message-Id: <p3cg349t9ldutlk768bse178jetlu96iql@4ax.com>
Bill H <bill@ts1000.us> wrote:
>Other than the reasons given above, is there any effeciency or speed
>benefits to using:
>open FILE, ">", "file";
>instead of:
>open(FILE,">file");
You are dealing with accessing a file system and -except in very special
cases like flash memory- with physical media that needs to be
moved/read/interpreted. Those steps are many orders of magnitude slower
than any speed gain you could possibly get from using one form over the
other within Perl.
jue
------------------------------
Date: Sat, 24 May 2008 17:42:35 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: maintaining order in a hash (without Tie::IxHash)
Message-Id: <r4tlg5-q422.ln1@osiris.mauzo.dyndns.org>
Quoth "comp.llang.perl.moderated" <ced@blv-sam-01.ca.boeing.com>:
>
[re: Tie::IxHash]
> I agree mostly. But, even stretching the hash's natural model a bit,
> an ordered hash is a convenient amenity at times. Also, with a big
> array and lots of lookups, even a slow tied hash could be faster.
Faster than...? Just an array, or an array and a hash in parallel? All
Tie::IxHash does for you is maintain a parallel hash and array, so the
tie overhead (not insignificant, if this is a performance-critical part
of the application) is on top of that.
Of course, attempting to emulate a hash by iterating through an array is
just daft... :)
Ben
--
The cosmos, at best, is like a rubbish heap scattered at random.
Heraclitus
ben@morrow.me.uk
------------------------------
Date: Sat, 24 May 2008 19:05:55 +0200
From: "Peter J. Holzer" <hjp-usenet2@hjp.at>
Subject: Re: Out of memory! Yet ...
Message-Id: <slrng3gino.p97.hjp-usenet2@hrunkner.hjp.at>
First, please don't quote the entire posting you are responding to, at
least not in a single block. Quote only the relevant parts and write
your replies immediately below them. I rearranged your posting to match:
On 2008-05-22 06:32, alexxx.magni@gmail.com <alexxx.magni@gmail.com> wrote:
> On 21 Mag, 18:11, "A. Sinan Unur" <1...@llenroc.ude.invalid> wrote:
>> "alexxx.ma...@gmail.com" <alexxx.ma...@gmail.com> wrote innews:e84cae72-e396-40a6-beec-4bad5aa3d615@d77g2000hsb.googlegroups.com:
>>
>> > I am having trouble running my script, which stops with an "Out of
>> > memory!" error.
>> > But what I find unusual is that it stops as soon as the "Free" memory
>> > reported by the <free> utility goes to zero - without even starting to
>> > touch the free swap memory (and I have 2GB swap).
>>
>> How much physical memory do you have and what OS are you on? Does it
>> actually support more than 2GB addressable memory space?
>
> 1)
>> How much physical memory do you have and what OS are you on? Does it
> actually support more than 2GB addressable memory space?
>
> maybe that's a hint: I use Linux, Fedora FC8. I have 4GB RAM, can it
> be this the problem?
32 bit or 64 bit system? On a 32 bit Linux system, a single process
cannot get more than 3 GB of virtual memory.
>> > where for $n times I read a grayscale image in @a, then assign its
>> > value to $AAA[][][].
>>
>> How large is the image? You are basically holding two copies of the
>> image in memory. Plus, you have the overhead of a multilevel data
>> structure.
> 2) concerning the huge overhead, I cannot avoid it - I need all the
> images (indexed by $i) in parallel in $AAA[$i][$x][$y],
You can tremendously reduce the overhead by not storing each pixel in an
array element of its own. A numeric array element in perl takes at least
20 bytes, possibly quite a bit more depending on your malloc library.
Assuming that your images are 8 bit greyscale, you are using at least 20
times more memory than you need to use. You could keep each row of the
images in a single string, which would reduce the overhead
significantly. Or you could use PDL
<http://search.cpan.org/~csoe/PDL-2.4.3/Basic/PDL.pm>, which was written
for manipulating large multidimensional arrays of numeric data.
hp
------------------------------
Date: Sat, 24 May 2008 19:20:42 +0200
From: "Peter J. Holzer" <hjp-usenet2@hjp.at>
Subject: Re: Out of memory! Yet ...
Message-Id: <slrng3gjjd.p97.hjp-usenet2@hrunkner.hjp.at>
On 2008-05-23 07:03, alexxx.magni@gmail.com <alexxx.magni@gmail.com> wrote:
> thank you for your answer!
> On 22 Mag, 18:25, s...@netherlands.co wrote:
>> Lets do a little bitmap math.
>>
>> Assume memory conservation:
>> 1600 x 1200 pixels x 1 byte/8-bit(plane's) gray scale = 1.9 MB
>> 100 gray scale images x 1.9 MB/image = 190 MB
>> Using 2 buffers = 380 MB
>>
>> Assume memory waste:
>> 1600 x 1200 pixels x 8 byte/8-bit(plane's) gray scale = 15.36 MB
>> 100 gray scale images x 15.36 MB/image = 1.536 GB
>> Using 2 buffers = 3.072 GB
>>
>
> I didnt understand well: memory conservation vs, waste, how can I be
> sure in perl that I use in my matrices 1 byte per pixel?
By storing them in strings (or using modules designed for storing
images).
> I believed that perl automatically choose by itself, and it was
> impossible to force "byte ($x,$y,$z)" in C-style.
Right. Perl does choose by itself, but it simply doesn't have any
datatype that small: On a 32bit debian system, perl 5.8.8 takes about 20
bytes for each integer, 29 bytes for each floating point number, and 45
bytes for each single-byte string.
hp
------------------------------
Date: Sat, 24 May 2008 13:44:51 -0700
From: sln@netherlands.co
Subject: Re: Out of memory! Yet ...
Message-Id: <6rqg34hnv4d0k2h5k7oqi44gj3ffdtsl49@4ax.com>
On Fri, 23 May 2008 00:03:30 -0700 (PDT), "alexxx.magni@gmail.com" <alexxx.magni@gmail.com> wrote:
>thank you for your answer!
>
>On 22 Mag, 18:25, s...@netherlands.co wrote:
>> On Wed, 21 May 2008 23:32:52 -0700 (PDT), "alexxx.ma...@gmail.com" <alexxx.ma...@gmail.com> wrote:
>> >On 21 Mag, 18:11, "A. Sinan Unur" <1...@llenroc.ude.invalid> wrote:
>> >> "alexxx.ma...@gmail.com" <alexxx.ma...@gmail.com> wrote innews:e84cae72-e396-40a6-beec-4bad5aa3d615@d77g2000hsb.googlegroups.com:
>>
>> --<snip>--
>>
>> >> > The memory-eating line is this:
>> >> > for $i(1..$n)
>> >> > {
>> >> > for $y(1..$ny)
>> >> > { for $x(1..$nx) { $AAA[$i][$x][$y]=$a[3+$nx*($y-1)+$x] } }
>> >> > print("\n$i>\ttotal size: ",total_size($AAA));
>> >> > }
>>
--<snip>--
>>
>> "..since I have"
>> ">to process each pixel ($x,$y) along $i=1..$n "
>>
>> Although a little confused, I thought this was interresting.
>>
>> You made some statements along with including this code:
>>
>> for $i(1..$n)
>> {
>> for $y(1..$ny)
>> {
>> for $x(1..$nx)
>> {
>> $AAA[$i][$x][$y]=$a[3+$nx*($y-1)+$x]
>> }
>>
>> }
>>
>> You said you are reading 100 gray scale images into @a,
>> flat file. Since the indices of $AAA never touch the same
>> element twice as an lvalue and since $AAA is never referenced
>> as an rvalue. This merely rearranges the values of @a into @AAA.
>> I am not sure this is a filter or even a conversion of say color to gray.
>
>
>well, as I said before, I didnt want to post a script too large to the
>group, so maybe I've been misunderstood: the images are read in
>sequence in @a, so that @a is overwritten each time - no memory waste
>there: it will just occupy between 2 and 15MB as you said. $AAA
>instead will hold all of them, and I'm unable to avoid this.
>
>A little background: the images are a temporal sequence of
>magnetooptical images representing the switching of magnetization, say
>from black to white, along time. This meas.tech. is very noisy. The
--<snip>-- I'll take your word on it ..
>
>Sorry if I didnt explain it before.
>
>>
>> Lets do a little bitmap math.
>>
>> Assume memory conservation:
>> 1600 x 1200 pixels x 1 byte/8-bit(plane's) gray scale = 1.9 MB
>> 100 gray scale images x 1.9 MB/image = 190 MB
>> Using 2 buffers = 380 MB
>>
>> Assume memory waste:
>> 1600 x 1200 pixels x 8 byte/8-bit(plane's) gray scale = 15.36 MB
>> 100 gray scale images x 15.36 MB/image = 1.536 GB
>> Using 2 buffers = 3.072 GB
>>
>
>I didnt understand well: memory conservation vs, waste, how can I be
>sure in perl that I use in my matrices 1 byte per pixel? I believed
>that perl automatically choose by itself, and it was impossible to
>force "byte ($x,$y,$z)" in C-style.
>
>Thanks again!
>
> Alessandro
>
>
In what your doing, memory conservation becomes important.
According to perldoc's, the default scalar number is a float.
And if you use bit-wise operations, the default integral type
is unsigned int. If you include "use integer" the default becomes
signed int. I don't know if or how that affects internal buffering of
number arrays, since arrays can hold a mixture of any perl type,
which would tend to use a large amount of memory resources.
However that affects your program, it affects everybody's the same way
and is uncontrollable. But the compiler does funny optimizations.
So the only thing you can do is to try to maximize space ala C-style,
and see what that gives you. If it doesen't work, no loss, try something
else.
I don't know how you are reading in the bitmap so I'm just guessing on this.
After looking at this equation $AAA[$i][$x][$y] = $a[3+$nx*($y-1)+$x];
it appears to be reading bytes, plus you mentioned 8-bit gray scale.
A byte is 8 bits so that makes sense.
And there does seem to be an ordering to it that resembles bit plane's,
in the y direction, so I'll just leave it for what it is.
This ordering can be seen in this series:
for y=1..1600
{
for x=1..1200
{ AAA[x][y] = a[3 + 1200*(y-1) + x] }
}
x=1..1200, y=1
-------------------
AAA[1][1] = a[3 + 1200*(1-1) + 1] = a[4]
AAA[2][1] = a[3 + 1200*(1-1) + 2] = a[5]
AAA[3][1] = a[3 + 1200*(1-1) + 3] = a[6]
AAA[1200][1] = a[3 + 1200*(1-1) + 1200] = a[1203]
x=1..1200, y=2
-------------------
AAA[1][2] = a[3 + 1200*(2-1) + 1] = a[1204]
AAA[2][2] = a[3 + 1200*(2-1) + 2] = a[1205]
AAA[3][2] = a[3 + 1200*(2-1) + 3] = a[1206]
AAA[1200][2] = a[3 + 1200*(2-1) + 1200] = a[2403]
Back to bitmap math, assume memory conservation:
1600 x 1200 pixels x 1 byte gray scale = 1.9 MB
The ideal situation is if you could use a block of memory
where every byte contained valid 8-bit color data.
Right now, it appears you are using a 32-bit element to
store an 8-bit color, wasting 3 bytes each time.
This is alright though. Its the way it is stored in the frame buffer,
and is enough room to hold a 24-bit color.
Since your doing image processing though, it might be a
good idea to use the remaining 3 byte's in each element.
In the example above, using all 4 byte's of the element
should only consume 1.9 MB.
A byte array can be simulated in the untested example below.
Note, that this can be done for 16-bit color as well.
Nothing beyond that though.
Acording to the perldoc's, bit manipulations should be fast
as they are close to C at low level.
sln
robic0(at)adelphia.net
Untested example:
@a = ();
@AAA = ();
for $i(1..$n)
{
# ... read another bitmap into $a
# ...
for $y(1..$ny)
{
for $x(1..$nx)
{
setColor8(\@AAA, $i, $x, $y, $a[3 + $nx*($y-1) + $x]);
## $AAA[$i][$x][$y] = $a[3+$nx*($y-1)+$x];
}
}
}
sub setColor8
{
my ($refimgarray, $img, $xpixel, $ypixel, $color) = @_
my $bitpos = ($ypixel & 3) * 8;
my $yelement = (($ypixel & 0xFFFFFFFB) >> 2) + 1;
my $refelement = \${$refimgarray}[$img][$xpixel][$yelement];
$$refelement = (($$refelement & ~(0xFF << $bitpos)) | (($color & 0xFF) << $bitpos)));
}
sub getColor8
{
my ($refimgarray, $img, $xpixel, $ypixel) = @_
my $bitpos = ($ypixel & 3) * 8;
my $yelement = (($ypixel & 0xFFFFFFFB) >> 2) + 1;
my $refelement = \${$refimgarray}[$img][$xpixel][$yelement];
return (($$refelement & (0xFF << $bitpos)) >> $bitpos);
}
------------------------------
Date: Sat, 24 May 2008 17:49:43 +0200
From: "Peter J. Holzer" <hjp-usenet2@hjp.at>
Subject: Re: Perl software?
Message-Id: <slrng3ge8q.p97.hjp-usenet2@hrunkner.hjp.at>
On 2008-05-20 14:20, amerar@iwc.net <amerar@iwc.net> wrote:
> GD:Graph looks like a pain in the ass to install. There seems to be
> so many libraries and modules that are needed.
That's what package systems are for. If you use cpan (or cpanp) to
install GD::Graph, it will also install all the modules it depends on.
Same thing for the package managers of various unix systems.
hp
------------------------------
Date: Sat, 24 May 2008 10:46:37 -0500
From: Tad J McClellan <tadmc@seesig.invalid>
Subject: Re: Perl vs. Php
Message-Id: <slrng3ge2t.2n2.tadmc@tadmc30.sbcglobal.net>
Bill H <bill@ts1000.us> wrote:
> Preface: This is not a flame war, please don't turn it into one.
That should be possible, since the Big Picture question here holds
true regardless of what languages frame the "versus".
> I am involved in a very large project
So there is like a dozen programmers working on ...
> that will be doing a lot of
> talking to Postgres databases (possibly using a a RST middleware). The
... this DB-accessing very large project?
> database guys want to use php for all of their stuff, I want to use
> perl for mine.
> The reasons I want to use perl are:
>
> 1) I have been working in it for 10+ years
How much experience do the 11 other people have with Perl (not perl)?
How much experience do you have with PHP?
> Is there a valid reason I should switch to php versus perl (or vice
> versa they switch to perl)?
What does your boss say about that?
She/he likely gets way more votes than any of us do...
Having code that can be maintained by only 1 of the people
available vs code that any of 11 people can work on would
be a terribly powerful argument for you to switch.
> Portability, ease of maintaining, speed of
> execution, security etc?
If 11 are experienced with DB work in PHP, and 1 is experienced with
DB work in Perl, then the "they switch to Perl" would win a cost-benefit
analysis only if Perl was at least 11 times better than PHP for this
application.
--
Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"
------------------------------
Date: 24 May 2008 16:46:58 GMT
From: Abigail <abigail@abigail.be>
Subject: Re: Range of number
Message-Id: <slrng3ghk1.2nh.abigail@alexandra.abigail.be>
_
David Formosa (aka ? the Platypus) (dformosa@usyd.edu.au) wrote on
VCCCLXXX September MCMXCIII in <URL:news:slrng3fifc.24i.dformosa@localhost.localdomain>:
"" On 23 May 2008 19:57:24 GMT, Abigail <abigail@abigail.be> wrote:
""
"" [...]
""
""
"" > As for other languages, IIRC, chained comparisons have always worked the
"" > way they will in Perl 6.
""
"" Perl 6 will be the first language I know of that will do chained comparisions.
"" Most others do them wrong. For example in C
""
"" (2<1<3)
""
"" Will return true, while in other languages such a chained comparison is a
"" type error.
Right. What I wanted to say was:
As for other languages, IIRC, *IN PYTHON*, chained comparisons
have always worked the way they will in Perl 6.
Abigail
--
A perl rose: perl -e '@}-`-,-`-%-'
------------------------------
Date: Sat, 24 May 2008 10:15:03 -0500
From: Tad J McClellan <tadmc@seesig.invalid>
Subject: Re: reference/alias in perl vs reference/alias in C++
Message-Id: <slrng3gc7n.2n2.tadmc@tadmc30.sbcglobal.net>
[ There is no C/C++ in this sub-question.
Newsgroups: modified.
]
grocery_stocker <cdalten@gmail.com> wrote:
> #!/usr/bin/perl -w
#!/usr/bin/perl
use warnings;
use strict;
> # global array definition
> my @array = ("a","b","c");
>
> sub print_array {
my @array = @_; # a different array, named the same as the 1st (outer) one
> foreach my $element (@array) {
> $element .= "9";
> print $element . "\n";
> }
>
> }
>
> for ($i = 0; $i < 3; $i++) {
> &print_array();
print_array(@array);
> }
>
> How would I prevent $elment from modifying @array?
See above.
See also:
perldoc -q "difference between calling"
"Coping with Scoping":
http://perl.plover.com/FAQs/Namespaces.html
--
Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"
------------------------------
Date: Sat, 24 May 2008 08:44:14 -0500
From: Tad J McClellan <tadmc@seesig.invalid>
Subject: Re: Regex for password checking
Message-Id: <slrng3g6te.2n2.tadmc@tadmc30.sbcglobal.net>
Owen <xemoth@gmail.com> wrote:
> Just wondering if [:print:], with a pretest for a space would meet all
> the requirements of a unix password. (mixed case, numbers, and
> symbols)
A "unix password" _can_ have space characters in it.
--
Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"
------------------------------
Date: Sat, 24 May 2008 16:10:32 +0200
From: "Dr.Ruud" <rvtol+news@isolution.nl>
Subject: Re: Using a buffer with HTTP::Response?
Message-Id: <g19emi.ko.1@news.isolution.nl>
Leif Wessman schreef:
> I'm parsing a text-file, line by line. But it is almost 100 MB.
> Is it possible to use a buffer instead of loading the complete
> text file into memory?
You don't want to buffer, you want to process line by line.
> my $req = new HTTP::Request GET => $url;
> my $ua = new LWP::UserAgent;
I would write those as:
my $req = HTTP::Request->new( GET => $url );
my $ua = LWP::UserAgent->new();
> my @lines = split /\n/, $res->content;
> foreach $line (@lines) {
> # do stuff
> }
while ( $res->content =~ m/ (.*) \n? /gx )
# do stuff with $1
}
--
Affijn, Ruud
"Gewoon is een tijger."
------------------------------
Date: Sat, 24 May 2008 16:44:12 +0200
From: "Dr.Ruud" <rvtol+news@isolution.nl>
Subject: Re: Using a buffer with HTTP::Response?
Message-Id: <g19gn0.1ho.1@news.isolution.nl>
Dr.Ruud schreef:
> while ( $res->content =~ m/ (.*) \n? /gx )
> # do stuff with $1
> }
Rather:
while ( $res->content =~ m/ (.*) \n? /gx ) {
# do stuff with $1
}
--
Affijn, Ruud
"Gewoon is een tijger."
------------------------------
Date: Sat, 24 May 2008 10:15:59 -0700 (PDT)
From: Keenlearner <yingun@gmail.com>
Subject: Yet another interface to SWI-Prolog in mod_perl
Message-Id: <36bbab2d-9261-4d5a-9e2e-081e33c3173f@j33g2000pri.googlegroups.com>
I am trying to run the Yaswi
http://search.cpan.org/~salva/Language-Prolog-Yaswi-0.14/Yaswi.pm
module in mod_perl,
use CGI qw(:standard);
print header;
use Language::Prolog::Yaswi qw(:query :run);
use Language::Prolog::Types::overload;
use Language::Prolog::Sugar functors => { equal => '=',
is => 'is' },
chains => { orn => ';',
andn => ',',
add => '+' },
vars => [qw (X Y Z)];
swi_set_query( equal(X, Y),
orn( equal(X, 27),
equal(Y, 'hello')));
while (swi_next) {
printf "Query=".swi_query()."\n";
printf " X=%_, Y=%_\n\n", swi_var(X), swi_var(Y);
}
at first I got error
[PROLOG SYSTEM ERROR: Thread 1
Recursively received fatal signal 11
PROLOG STACK:
]
It happend to solve that problem in Java, we need to add -nosignals
So I add
swi_init('-nosignals');
But now I got errors of
[Thu May 22 17:07:48 2008] [notice] child pid 13466 exit signal
Segmentation fault (11)
[Thu May 22 17:07:48 2008] [notice] child pid 13492 exit signal
Segmentation fault (11)
[Thu May 22 17:07:48 2008] [notice] child pid 13493 exit signal
Segmentation fault (11)
[Thu May 22 17:07:48 2008] [notice] child pid 13494 exit signal
Segmentation fault (11)
[Thu May 22 17:07:48 2008] [notice] child pid 13495 exit signal
Segmentation fault (11)
Is it possible to run Yaswi in mod_perl ? I got not problem when using
CGI, Thanks.
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
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: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice.
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 V11 Issue 1575
***************************************