[28362] in Perl-Users-Digest
Perl-Users Digest, Issue: 9726 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Sep 14 18:06:02 2006
Date: Thu, 14 Sep 2006 15:05:05 -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 Thu, 14 Sep 2006 Volume: 10 Number: 9726
Today's topics:
Re: converting php md5 function to perl checarsner@gmail.com
Re: Functional Test Using WWW:Mechanize <benmorrow@tiscali.co.uk>
Re: Functional Test Using WWW:Mechanize <mumebuhi@gmail.com>
Re: How to tie Perl script with cgi <mumia.w.18.spam+nospam.usenet@earthlink.net>
Re: I/O with raw disk <RedGrittyBrick@SpamWeary.foo>
Re: Maximum number of sockets <sisyphus1@nomail.afraid.org>
Re: Maximum number of sockets <sisyphus1@nomail.afraid.org>
Re: Maximum number of sockets <angusma@attglobal.net>
Preventing changes to a module's variables in mod_perl max@maxgraphic.com
Re: Preventing changes to a module's variables in mod_p <tzz@lifelogs.com>
Re: String buffer instead of file handle? <tzz@lifelogs.com>
Re: String buffer instead of file handle? <danparker276@yahoo.com>
Re: String buffer instead of file handle? <RedGrittyBrick@SpamWeary.foo>
Re: String buffer instead of file handle? <danparker276@yahoo.com>
Re: String buffer instead of file handle? <danparker276@yahoo.com>
Re: String buffer instead of file handle? <RedGrittyBrick@SpamWeary.foo>
Re: XML content element parsing <nobull67@gmail.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 14 Sep 2006 11:22:07 -0700
From: checarsner@gmail.com
Subject: Re: converting php md5 function to perl
Message-Id: <1158258127.679465.69190@e3g2000cwe.googlegroups.com>
Thanks for the answer John. Would you be willing to explain the
transition from the php version to the perl version? It seems like we
are missing an encryption step to me.
John wrote:
> Hi
>
> I've pulled this from my site
>
> use Digest::MD5 qw (md5_hex); # 32 character hex hash
> my $hash=uc(md5_hex($message)); # uppercase
>
> Regards
> John
>
>
> <checarsner@gmail.com> wrote in message
> news:1158092199.849372.326210@e3g2000cwe.googlegroups.com...
> > Hey all
> >
> > how I can convert the PHP password encryption into a Perl function
> > which generates the same result...
> > I am completely stuck at this point... My PHP knowledge is close to
> > zero. I understand their procedure but when I do it in Perl it comes
> > back with a different result...
> > in PHP: $newPw["userPassword"] = '{md5}' .
> > base64_encode(pack('H*',md5($newPasswd)));
> > sorry the help file is a place where we deffinitly will not find
> > anything..
> > the problem is not, understanding what the PHP code is doing. The issue
> > is to make Perl do the same.
> >
> > TIA
> >
> > Che
> >
------------------------------
Date: Thu, 14 Sep 2006 17:51:52 +0100
From: Ben Morrow <benmorrow@tiscali.co.uk>
Subject: Re: Functional Test Using WWW:Mechanize
Message-Id: <8udot3-kdg.ln1@osiris.mauzo.dyndns.org>
Quoth "mumebuhi" <mumebuhi@gmail.com>:
> I am trying to _design_ an automated test suite for web functional test
> using WWW::Mechanize. I am not sure whether to design it more OO or
> procedural.
>
> Consider this simple scenarios. I need to automate the following two
> use cases.
> 1. Login -> Enter Form A and submit -> Logout
> 2. Login -> Click Link B -> Enter Form B and submit -> Logout
> >From these two simple use cases, there are two "identical" actions:
> Login and Logout.
>
> If we create use case 1 in one (Perl) script and use case #2 in another
> script (more procedural), then we will have unnecessary redundancy. As
> we all realize, this type of redundancy might lead to maintenance
> problem when the test suite grows larger.
Writing two separate scripts with common code is not 'more procedural',
it's just redundant :). The standard way of factoring out common code in
Perl is to use modules; these can provide either a procedural or an OO
interface (or, indeed, both).
The usual reasons for using OOP are
1. You have some state you need to carry about between calls, which
you hide inside you object; e.g. in this case you might want a
WWW::Mech object plus some state about how far through the
transaction you are passed from one call to the next: you can do
this by packing it all up into an object.
2. You want to be able to create variations on your interface or its
implementation.
In a case like this I would probably create an OO interface first, and
then write a set of functional wrappers around it because they're
usually easier to use. An example of the sort of thing I mean is
CGI.pm's two interfaces.
Ben
--
Like all men in Babylon I have been a proconsul; like all, a slave ... During
one lunar year, I have been declared invisible; I shrieked and was not heard,
I stole my bread and was not decapitated.
~ benmorrow@tiscali.co.uk ~ Jorge Luis Borges, 'The Babylon Lottery'
------------------------------
Date: 14 Sep 2006 14:03:49 -0700
From: "mumebuhi" <mumebuhi@gmail.com>
Subject: Re: Functional Test Using WWW:Mechanize
Message-Id: <1158267829.300719.132680@e3g2000cwe.googlegroups.com>
Thank you.
Let's continue with this discussion. Assume that I have a module with
the approrpiate wrapper subroutines, something like
# start
package MyMech;
sub new { ... }
sub login { ... }
sub fill_formA_and_submit { ... }
sub fill_formB_and_submit { ... }
sub click_linkB { ... }
1;
# end
Since a user needs to login before (s)he can use the site,
'fill_formA_and_submit' requires 'login' to be executed first. Which
one of these is better, A or B?
A. To have a caller to this module to call 'login' then
'fill_formA_and_submit' and do validation? That is, having the
validation done in the caller.
B. To call 'login' from 'fill_formA_and_submit'? That is, 'login' has
its own validation rules and so does 'fill_formA_and_submit'.
Thank you.
Buhi
------------------------------
Date: Thu, 14 Sep 2006 18:23:19 GMT
From: "Mumia W." <mumia.w.18.spam+nospam.usenet@earthlink.net>
Subject: Re: How to tie Perl script with cgi
Message-Id: <r6hOg.12034$xQ1.6740@newsread3.news.pas.earthlink.net>
On 09/14/2006 11:00 AM, Vinay Nagrik wrote:
> Hello group,
>
> I am just introduced to Perl and written my first program. I need to
> fire it through a cgi script.
>
> Could someone tell me how to tie two programs together so that when I
> send a post request through uri, my script gets fired.
>
> Thanks in advance.
>
> nagrik
>
http://www.w3.org/TR/html4/interact/forms.html#adef-action
Either an HTML page or a CGI script will present a form to the
user, and that form's action attribute will point to your
form-processing CGI script.
It's a good idea to know HTML before trying to write CGI scripts.
------------------------------
Date: Thu, 14 Sep 2006 22:44:27 +0100
From: RedGrittyBrick <RedGrittyBrick@SpamWeary.foo>
Subject: Re: I/O with raw disk
Message-Id: <t5WdndUzLbJOV5TYnZ2dnUVZ8s2dnZ2d@bt.com>
dcruncher4@aim.com wrote:
> How can I open a raw disk file and write to it. I have to write a
> program which will
> write few gigs of data to both raw disk and a cooked file to compare
> the write
> performance.
>
> Which functions to use for that.
>
Can't you use the usual functions for both? At least on Unix like systems.
Untested ...
----------------------------------8<---------------------------------
#!perl
use strict;
use warnings;
my $rawdisk = '/dev/hdb2';
my $cookedfile = '/tmp/foo';
write_gigabytes($rawdisk);
write_gigabytes($cookedfile);
sub write_gigabytes {
my $targetname = shift;
my $start=time;
open my $fh, '>', $targetname
or die "Unable to open '$targetname' for writing because $!\n";
print $fh 'a few gigs of data'
or die "Unable to write to '$targetname' because $!\n";
close $fh
or die "Unable to close '$targetname' because $!\n";
print "writing a few gigs of data to '$targetname' took ",
time-$start, "s.\n";
}
----------------------------------8<---------------------------------
Even assuming the above is remotely like a functional perl program, I
have doubts that this sort of exercise will measure anything useful.
P.S. the point of the above is not to identify I/O operations suited to
the OP's real problem domain but to illustrate that on some platforms
the O/S presents a fairly consistent file-like interface for all sorts
of odd things. I can't remember if /dev/hdb2 is likely to be character
mode or block mode, or whether either case would prevent the above
program from "working".
------------------------------
Date: Fri, 15 Sep 2006 04:44:22 +1000
From: "Sisyphus" <sisyphus1@nomail.afraid.org>
Subject: Re: Maximum number of sockets
Message-Id: <4509a412$0$21803$afc38c87@news.optusnet.com.au>
"A Ma" <angusma@attglobal.net> wrote in message
.
.
>
> I made the change and was able to build a new version of Perl. However,
the
> change of PERL_FD_SETSIZE in socket.h didn't seem to make any difference.
You changed the socket.h that's in win32/sys (not wince/sys) ?
I can also find a lib/CORE/sys/socket.h - which I assume is the socket.h
that gets written for inclusion into the perl installation. Does the entry
for PERL_FD_SETSIZE in lib/CORE/sys/socket.h match the entry in
win32/sys/socket.h ?
It may well be that the task is not as simple as we've assumed ......
Cheers,
Rob
------------------------------
Date: Fri, 15 Sep 2006 04:49:40 +1000
From: "Sisyphus" <sisyphus1@nomail.afraid.org>
Subject: Re: Maximum number of sockets
Message-Id: <4509a550$0$11969$afc38c87@news.optusnet.com.au>
"Michele Dondi" <bik.mido@tiscalinet.it> wrote in message
.
.
> Do they consider compatibility with MinGW a requirement of their
> source code?
Good question - and I don't really know for sure, but I *think* they would
try to keep their code MinGW-compatible .... I guess time will tell :-)
Cheers,
Rob
------------------------------
Date: Thu, 14 Sep 2006 17:01:20 -0400
From: "A Ma" <angusma@attglobal.net>
Subject: Re: Maximum number of sockets
Message-Id: <4509c327@kcnews01>
"Sisyphus" <sisyphus1@nomail.afraid.org> wrote in message
news:45089738$0$5110$afc38c87@news.optusnet.com.au...
>
May be I am hitting some other limit instead of FD_SETSIZE. This is my test
program:
my $pselect = IO::Select->new();
for ($i=0;$i<=100;$i++) {
my $port = $i + 500;
if ($server[$i] = IO::Socket::INET->new(LocalPort => $port,
Type => SOCK_STREAM,
Reuse => 1,
Listen => 10 )) {
$pselect->add($server[$i]);
} else {
print "Cannot open port $port.\n";
$server[$i] = 0;
}
}
$done = 0;
while ($done == 0) {
foreach $client ($pselect ->can_read(0.5)) {
my $newconn = 0;
for ($i=0;$i<=100;$i++) {
if ($client == $server[$i]) {
# accept a new connection
$client = $server[$i]->accept();
$pselect->add($client);
printf "Received a call on port %d\n", $i+500;
$newconn = 1;
}
}
}
}
This program listens to TCP ports 500 to 600. I can connect from ports 500
to 563. Beyond that, the test program cannot see the incoming connection.
Any ideas?
------------------------------
Date: 14 Sep 2006 11:55:36 -0700
From: max@maxgraphic.com
Subject: Preventing changes to a module's variables in mod_perl
Message-Id: <1158260136.683094.264860@i42g2000cwa.googlegroups.com>
I have a module that exists as a central data store, returning simple
scalars or references to larger structures. All of its data is stored
in a big hash, and I use AUTOLOAD to return the requested value.
The problem is that, with mod_perl, if the script that uses the module
changes the data (which with auto-vivication is pretty easy), the data
is changed for all subsequent scripts using that module run by that
particular apache child, which leads to the usual hair-pulling
intermittent bugs that mod_perl users historically puzzle over.
I've looked at a couple locking options, but the problem is that the
data can be arbitrarily deep references (which seems to rule out
Hash::Util). I might have MyModule->foo->{bar}{$baz}, and if $baz isn't
a valid key, it gets auto-vivified and there goes my weekend.
Is there a way I can prevent these changes from happening? And without
a huge performance penalty?
Thanks.
------------------------------
Date: Thu, 14 Sep 2006 15:37:52 -0400
From: Ted Zlatanov <tzz@lifelogs.com>
Subject: Re: Preventing changes to a module's variables in mod_perl
Message-Id: <g691wqetf1r.fsf@CN1374059D0130.kendall.corp.akamai.com>
On 14 Sep 2006, max@maxgraphic.com wrote:
> I have a module that exists as a central data store, returning simple
> scalars or references to larger structures. All of its data is stored
> in a big hash, and I use AUTOLOAD to return the requested value.
>
> The problem is that, with mod_perl, if the script that uses the module
> changes the data (which with auto-vivication is pretty easy), the data
> is changed for all subsequent scripts using that module run by that
> particular apache child, which leads to the usual hair-pulling
> intermittent bugs that mod_perl users historically puzzle over.
>
> I've looked at a couple locking options, but the problem is that the
> data can be arbitrarily deep references (which seems to rule out
> Hash::Util). I might have MyModule->foo->{bar}{$baz}, and if $baz isn't
> a valid key, it gets auto-vivified and there goes my weekend.
Can you return a tied hash where you control each operation on the
hash (retaining the syntax you have) to the effect you want? There
may even be a CPAN module that does what you want, though I'm not
aware of it.
Ted
------------------------------
Date: Thu, 14 Sep 2006 15:45:44 -0400
From: Ted Zlatanov <tzz@lifelogs.com>
Subject: Re: String buffer instead of file handle?
Message-Id: <g69u03as047.fsf@CN1374059D0130.kendall.corp.akamai.com>
On 14 Sep 2006, danparker276@yahoo.com wrote:
> being a .net programmer puts me on a higher evolutionary scale, and
> I get more chicks that way.
So you've evolved into a chicken? That explains a *lot* about .Net
programmers.
Ted
------------------------------
Date: 14 Sep 2006 13:37:05 -0700
From: "danparker276@yahoo.com" <danparker276@yahoo.com>
Subject: Re: String buffer instead of file handle?
Message-Id: <1158266225.453625.111650@p79g2000cwp.googlegroups.com>
Serious? Was that supposed to be funny? I scored with 2 chicks last
weekend! Think about that next time your home alone on friday night.
Ted Zlatanov wrote:
> On 14 Sep 2006, danparker276@yahoo.com wrote:
>
> > being a .net programmer puts me on a higher evolutionary scale, and
> > I get more chicks that way.
>
> So you've evolved into a chicken? That explains a *lot* about .Net
> programmers.
>
> Ted
------------------------------
Date: Thu, 14 Sep 2006 23:00:44 +0100
From: RedGrittyBrick <RedGrittyBrick@SpamWeary.foo>
Subject: Re: String buffer instead of file handle?
Message-Id: <BtadnaI5H7k3U5TYRVnygQ@bt.com>
danparker276@yahoo.com wrote:
> Brian McCauley wrote:
>
>>Michele Dondi wrote:
>>
>>
>>>On 13 Sep 2006 15:31:58 -0700, "danparker276@yahoo.com"
>>><danparker276@yahoo.com> wrote:
>>>
>>>
>>>>Why does everyone have to always say "read the docs". This is
>>>
>>>Because some people tries very hard to keep the docs up to date and
>>>rich and helpful, maybe? Because it is the best way to teach one how
>>>to find quickly help without bothering people with questions that do
>>>not really deserve being asked?
>>
>>That's only part of it. There's also the fact that to an experienced
>>programmer just looking at an inappropriate denormalization is painful.
>>Retyping information that's covered in the standard docs is a
>>denomalization. So even if it weren't for the fact that it's more
>>effort for the person answering and less help to the person asking I'd
>>still be uncomfortable retyping.
>
>
> So if your friend asked you what's on TV tonight (and you know you were
> watching Prison Break), you'd tell him "Look it up in the TV guide".
> It's called being nice.
How about if some total stranger shouted out "whats on TV tonight"
whilst holding a TV guide in their hands?
------------------------------
Date: 14 Sep 2006 15:00:19 -0700
From: "danparker276@yahoo.com" <danparker276@yahoo.com>
Subject: Re: String buffer instead of file handle?
Message-Id: <1158271219.897328.114280@e3g2000cwe.googlegroups.com>
I'd tell her what's on, and then her and all her model friends would
then want to watch it at my place.
RedGrittyBrick wrote:
> danparker276@yahoo.com wrote:
> > Brian McCauley wrote:
> >
> >>Michele Dondi wrote:
> >>
> >>
> >>>On 13 Sep 2006 15:31:58 -0700, "danparker276@yahoo.com"
> >>><danparker276@yahoo.com> wrote:
> >>>
> >>>
> >>>>Why does everyone have to always say "read the docs". This is
> >>>
> >>>Because some people tries very hard to keep the docs up to date and
> >>>rich and helpful, maybe? Because it is the best way to teach one how
> >>>to find quickly help without bothering people with questions that do
> >>>not really deserve being asked?
> >>
> >>That's only part of it. There's also the fact that to an experienced
> >>programmer just looking at an inappropriate denormalization is painful.
> >>Retyping information that's covered in the standard docs is a
> >>denomalization. So even if it weren't for the fact that it's more
> >>effort for the person answering and less help to the person asking I'd
> >>still be uncomfortable retyping.
> >
> >
> > So if your friend asked you what's on TV tonight (and you know you were
> > watching Prison Break), you'd tell him "Look it up in the TV guide".
> > It's called being nice.
>
> How about if some total stranger shouted out "whats on TV tonight"
> whilst holding a TV guide in their hands?
------------------------------
Date: 14 Sep 2006 15:01:18 -0700
From: "danparker276@yahoo.com" <danparker276@yahoo.com>
Subject: Re: String buffer instead of file handle?
Message-Id: <1158271278.878647.119940@e3g2000cwe.googlegroups.com>
I love chicks that can't read.
RedGrittyBrick wrote:
> danparker276@yahoo.com wrote:
> > Brian McCauley wrote:
> >
> >>Michele Dondi wrote:
> >>
> >>
> >>>On 13 Sep 2006 15:31:58 -0700, "danparker276@yahoo.com"
> >>><danparker276@yahoo.com> wrote:
> >>>
> >>>
> >>>>Why does everyone have to always say "read the docs". This is
> >>>
> >>>Because some people tries very hard to keep the docs up to date and
> >>>rich and helpful, maybe? Because it is the best way to teach one how
> >>>to find quickly help without bothering people with questions that do
> >>>not really deserve being asked?
> >>
> >>That's only part of it. There's also the fact that to an experienced
> >>programmer just looking at an inappropriate denormalization is painful.
> >>Retyping information that's covered in the standard docs is a
> >>denomalization. So even if it weren't for the fact that it's more
> >>effort for the person answering and less help to the person asking I'd
> >>still be uncomfortable retyping.
> >
> >
> > So if your friend asked you what's on TV tonight (and you know you were
> > watching Prison Break), you'd tell him "Look it up in the TV guide".
> > It's called being nice.
>
> How about if some total stranger shouted out "whats on TV tonight"
> whilst holding a TV guide in their hands?
------------------------------
Date: Thu, 14 Sep 2006 23:14:57 +0100
From: RedGrittyBrick <RedGrittyBrick@SpamWeary.foo>
Subject: Re: String buffer instead of file handle?
Message-Id: <NtOdnUOt1utkTJTYRVnytw@bt.com>
danparker276@yahoo.com wrote:
> .NET 2.0 blows
I was wondering why you were struggling with perl when you could be
dashing off a quick .NET 2.0 replacement.
Aren't any of your 9000 MySpace friends any good at .NET 2.0 either?
Maybe they can help?
------------------------------
Date: 14 Sep 2006 11:31:59 -0700
From: "Brian McCauley" <nobull67@gmail.com>
Subject: Re: XML content element parsing
Message-Id: <1158258719.082351.59740@b28g2000cwb.googlegroups.com>
Sharif Islam wrote:
> my %attributes = %{$elements->{'Attributes'}};
> foreach( keys( %attributes )) {
> # save the login id
> $id = $attributes{$_} ;
> }
This is a rather complicated way to get the _last_ value from
%{$elements->{Attributes}}. There's no need to copy the hash nor
interate over it.
But since hashes are inherently unordered this only makes sense to get
the last value if you are really happy to get any value from the hash.
And it's a lot simpler to get the fist!
($id) = values %{$elements->{Attributes}};
On the other hand if you knew in advance the key you were looking for
in the hash it would be simpler to say:
$id = $elements->{Attributes}{login};
------------------------------
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 V10 Issue 9726
***************************************