[28332] in Perl-Users-Digest
Perl-Users Digest, Issue: 9696 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Sep 7 06:05:41 2006
Date: Thu, 7 Sep 2006 03: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, 7 Sep 2006 Volume: 10 Number: 9696
Today's topics:
A Perl web server: reading a client's request saridski@gmail.com
Re: IIS 6.0 perl problem <ksperle@hotmail.com>
Re: IO::Socket server <deadpickle@gmail.com>
Re: IO::Socket server <spp_icarsNOSPAM@yahoo.fr>
Re: Issue with select statements, vertical bars? <betterdie@gmail.com>
Re: Issue with select statements, vertical bars? <nobull67@gmail.com>
new CPAN modules on Thu Sep 7 2006 (Randal Schwartz)
Re: Numerical sort (Schwartzian xform) <john@castleamber.com>
Re: Numerical sort (Schwartzian xform) <uri@stemsystems.com>
Re: Problems detecting multiple clients <bryan@worldspice.net>
Re: time icrement based loop <deadpickle@gmail.com>
Re: Ultimate programmer's reference - Quickref.org laun <1usa@llenroc.ude.invalid>
Re: Using named constants in cases of a switch axel@white-eagle.invalid.uk
Re: XM::Simple - counting tags <john1949@yahoo.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 7 Sep 2006 02:33:05 -0700
From: saridski@gmail.com
Subject: A Perl web server: reading a client's request
Message-Id: <1157621584.874061.42010@i42g2000cwa.googlegroups.com>
Hi there,
I have been traversing the groups looking for an answer to a problem
that i am having. I have written a web server in Perl. I want to be
able to read clients' requests from the beginning of the request (GET /
HTTP/1.0) all the way to the end of the request (after the header if a
GET or after the payload if a POST). Currently, I can read the request
till the end but the browser (and the server) hangs at the end of the
request, as there is no end of request marker.
sub _bind($) {
socket($server, AF_INET, SOCK_STREAM, $self->{_CONFIG}->protocol()) ||
die("socket(): $!");
my $paddr = sockaddr_in($self->{_CONFIG}->port(), INADDR_ANY);
bind($server, $paddr) || die("bind(): $!");
listen($server, SOMAXCONN) || die("listen(): $!");
while(my $clientAddr = accept($client, $server)) {
$client->autoflush(1);
my ($port, $packed_ip) = sockaddr_in($clientAddr);
my $dotted_quad = inet_ntoa($packed_ip);
print("Connection [".localtime(time)."] from [$dotted_quad]\n");
handleclient($client, $server, $dotted_quad);
}
}
...
sub handleclient ($$$) {
my $self = shift();
my $client = shift();
my $server = shift();
my $clientip = shift();
my $line = <$client>;
# GET /index.html HTTP/1.1
$line =~ m/^(\w+)\s+(\S+)(?:\s+(\S+))?\r?$/;
$self->{_METHOD} = $1 || '';
$self->{_RESOURSE} = $2 || '';
$self->{_PROTOCOL} = $3 || '';
my @array = split(/\?/, $self->{_RESOURSE});
@{$self->{_FOLDERS}} = split(/\//, $array[0]);
$self->{_FILE} = pop(@{$self->{_FOLDERS}});
my $seperator = rindex($self->{_FILE}, "\.");
$self->{_FILEBASE} = substr($self->{_FILE}, 0, $seperator);
$self->{_FILEEXTENSION} = substr($self->{_FILE}, $seperator);
my @line = ();
my @temp = ();
%headers = ();
my $buffer = "";
my $count = 0;
my $li = undef;
while (defined(my $data = <$client>)) {
@line = split(/:/, $data);
%headers->{$line[0]} = $line[1];
}
}
The problem is clearly that once the the entire request is read, the
connection between the client's browser and the server hangs. I would
like the server to be as robust as possible and to be as generic as
possible. With this I mean that I want it to be RFC compliant but at
the same time, the server must be able to break the connection with the
client if the request has no end of request marker (of some kind).
I look forward to hearing from you all!
Best,
S.
------------------------------
Date: 6 Sep 2006 18:29:53 -0700
From: "Kevin_S" <ksperle@hotmail.com>
Subject: Re: IIS 6.0 perl problem
Message-Id: <1157592593.857239.43880@h48g2000cwc.googlegroups.com>
Thanks, I'll try a MS Server or IIS newsgroup.
Tad McClellan wrote:
> Kevin_S <ksperle@hotmail.com> wrote:
>
> > If I go to the cmd prompt I can run "perl -v" and get the proper
> > output
> >
> > I have to be missing a permission or missing a setting to make scripts
> > allowed somewhere right?
>
>
> Right.
>
>
> > Anyone got any ideas on where to start
>
>
> comp.infosystems.www.servers.ms-windows
>
>
> > or how to further narrow down my
> > problem?
>
>
> You can eliminate Perl as the cause of the problem.
>
> You do not have a Perl problem, you have a web server configuration
> problem.
>
> Web server configuration is off-topic in the Perl newsgroup.
>
>
> --
> Tad McClellan SGML consulting
> tadmc@augustmail.com Perl programming
> Fort Worth, Texas
------------------------------
Date: 6 Sep 2006 20:14:25 -0700
From: "deadpickle" <deadpickle@gmail.com>
Subject: Re: IO::Socket server
Message-Id: <1157598865.342726.300860@m73g2000cwd.googlegroups.com>
S=E9bastien Cottalorda wrote:
> deadpickle@gmail.com a =E9crit :
> > This is what I got:
> > server.pl
> > use strict;
> > use IO::Socket;
> > my $sock =3D new IO::Socket::INET(
> > LocalHost =3D> 'localhost',
> > LocalPort =3D> 7890,
> > Proto =3D> 'tcp',
> > Listen =3D> SOMAXCONN,
> > Reuse =3D> 1);
> > $sock or die "no socket :$!";
> > my($new_sock, $c_addr, $buf);
> > while (($new_sock, $c_addr) =3D $sock->accept()) {
> > my ($client_port, $c_ip) =3D
> > sockaddr_in($c_addr);
> > my $client_ipnum =3D inet_ntoa($c_ip);
> > my $client_host =3D
> > gethostbyaddr($c_ip, AF_INET);
> > print "got a connection from: $client_host",
> > " [$client_ipnum]\n";
> > while (defined ($buf =3D <$new_sock>)) {
> > print $buf;
> > }
> > }
> >
> > client.pl
> > use strict;
> > use IO::Socket;
> > my $file =3D
> > my $host =3D shift || 'localhost';
> > my $port =3D shift || 7890;
> > my $sock =3D new IO::Socket::INET(
> > PeerAddr =3D> $host,
> > PeerPort =3D> $port,
> > Proto =3D> 'tcp');
> > $sock or die "no socket :$!";
> >
> > What I want it to do is have the server on one computer and the client
> > on the other. I want the client to connect to the server and request a
> > file. I want the server to send the file to the client. Its a simple
> > text file so its not very large. I want it to do this over again until
> > it is closed. I dont know much about perl programming so any help would
> > be very appriciated.
> >
> Hi,
>
> Here are some clues:
>
> Server side:
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
> Examine what you've received from the client (you ever listen first)
> 1-/ if client sent you "FILE|...", the second column is a filename, open
> it (send "NACK|reason" if you're unable to open file) and send it
> through the socket with "FIL|" before
> 2-/ if client sent you "QUIT|", then close the socket (Normally never use=
d)
> 3-/ Else, reply "NACK|Command not understood"
> In every case, after the job, close the socket.
>
> [snip]
> while (defined ($buf =3D <$new_sock>)) {
> chomp($buf);
> if ($buf=3D~/^FILE\|/){
> my $filename =3D (split /\|/, $buf)[1];
> unless (open (FH, "<", $filename)){
> print $new_sock "NACK|File '$filename' do not exists\n";
> }
> else {
> while (my $line =3D<FH>){
> chomp($line);
> print $new_sock "FIL|".$line."\n";
> }
> close(FH);
> print $new_sock "EOT|\n";
> }
> last;
> }
> elsif ($buf=3D~/^QUIT\|/){
> last;
> else {
> print $new_sock "NACK|Command not understood\n";
> last;
> }
> }
> close ($new_sock);
>
>
>
> Client side:
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
> The client talk first in every case:
>
> use strict;
> use IO::Socket;
> my $file =3D
> my $host =3D shift || 'localhost';
> my $port =3D shift || 7890;
> my $sock =3D new IO::Socket::INET(
> PeerAddr =3D> $host,
> PeerPort =3D> $port,
> Proto =3D> 'tcp');
> $sock or die "no socket :$!";
> #--------------/ Socket opened \----------------
> $filename=3D......; # the file to be sent by the server side
> $fileout=3D.....; # the file in which we should place received datas
> unless (open (FH_RECEPTION, ">", $fileout)){
> die "Unable to create $fileout $!";
> }
> print $sock "FILE|$filename\n";
> my @elem=3D();
> my $all_received;
> while (my $line=3D<$sock>){
> chomp($line);
> @elem =3D split /\|/, $line;
> if ($elem[0]=3D~/^FIL\|/){
> print FH_RECEPTION $elem[1]."\n";
> $all_received=3D0;
> }
> elsif ($elem[0]=3D~/^EOT\|/){
> print "Normal End of Transmission received\n";
> $all_received=3D1;
> last;
> }
> elsif ($elem[0]=3D~/^NACK\|/){
> print "ERROR: $elem[1]\n";
> last;
> }
> else {
> print "Do not understand|$line\n";
> last;
> }
> }
> close($sock);
> close(FH_RECEPTION);
> if ((defined $all_received) and ($all_received=3D=3D1)){
> print "Everything has been received in $fileout\n";
> }
> elsif (defined $all_received) {
> print "some part of the file has been received in $fileout\n";
> }
>
> BE CAREFULL0: I consider that you're file didn't contains the '|'
> character. If so, you should replace it with another not used character.
> BE CAREFULL1: on both server and client side, as coded, you don't manage
> timeouts : use IO::Select for that.
> BE CAREFULL2: I didn't check the codes.
>
> Hope this helps.
>
> Sebastien
I copied this program and it works but the file that is transfered does
not contain any data.
------------------------------
Date: Thu, 07 Sep 2006 09:07:33 +0200
From: =?ISO-8859-1?Q?S=E9bastien_Cottalorda?= <spp_icarsNOSPAM@yahoo.fr>
Subject: Re: IO::Socket server
Message-Id: <44ffc536$0$31443$626a54ce@news.free.fr>
Hi,
Here is a full, tested, couple of program that work on an html file.
client_side.pl
==============
#!/usr/bin/perl -w
#
#
use strict;
use IO::Socket;
$|=1;
my $file =
my $host = shift || 'localhost';
my $port = shift || 7890;
my $sock = new IO::Socket::INET(
PeerAddr => $host,
PeerPort => $port,
Proto => 'tcp');
$sock or die "no socket :$!";
#--------------/ Socket opened \----------------
my $filename=.....; # the file to be sent by the server side
my $fileout=$filename."_RECEIVED"; # the file in which we should place
received datas
unless (open (FH_RECEPTION, ">", $fileout)){
die "Unable to create $fileout $!";
}
print $sock "FILE|$filename\n";
my @elem=();
my $all_received;
while (my $line=<$sock>){
chomp($line);
#
# Remove the next line in production
#
print "RECEIVED>$line\n";
@elem = split /\|/, $line;
if ($line=~/^FIL\|/){
$elem[1]='' unless (defined $elem[1]);
print FH_RECEPTION $elem[1]."\n";
$all_received=0;
}
elsif ($line=~/^EOT\|/){
print "Normal End of Transmission received\n";
$all_received=1;
last;
}
elsif ($line=~/^NACK\|/){
print "ERROR: $elem[1]\n";
last;
}
else {
print "Do not understand|$line\n";
last;
}
}
close($sock);
close(FH_RECEPTION);
if ((defined $all_received) and ($all_received==1)){
print "Everything has been received in $fileout\n";
}
elsif (defined $all_received) {
print "some part of the file has been received in $fileout\n";
}
exit;
server_side
===========
#!/usr/bin/perl -w
use strict;
use IO::Socket;
my $sock = new IO::Socket::INET(
LocalHost => 'localhost',
LocalPort => 7890,
Proto => 'tcp',
Listen => SOMAXCONN,
Reuse => 1);
$sock or die "no socket :$!";
$|=1;
my($new_sock, $c_addr, $buf);
while (($new_sock, $c_addr) = $sock->accept()) {
my ($client_port, $c_ip) = sockaddr_in($c_addr);
my $client_ipnum = inet_ntoa($c_ip);
my $client_host = gethostbyaddr($c_ip, AF_INET);
print "got a connection from: $client_host"," [$client_ipnum]\n";
while (defined ($buf = <$new_sock>)) {
chomp($buf);
if ($buf=~/^FILE\|/){
my $filename = (split /\|/, $buf)[1];
unless (open (FH, "<", $filename)){
print $new_sock "NACK|File '$filename'
do not exists\n";
}
else {
while (my $line =<FH>){
chomp($line);
print $new_sock "FIL|".$line."\n";
#
# Remove/comment next line in production
#
print "SENT>FIL|".$line."\n";
}
close(FH);
print $new_sock "EOT|\n";
}
last;
}
elsif ($buf=~/^QUIT\|/){
last;
}
else {
print $new_sock "NACK|Command not understood\n";
last;
}
}
close($new_sock);
}
exit;
Hope this helps again.....
Sebastien
------------------------------
Date: 6 Sep 2006 21:11:11 -0700
From: "paul" <betterdie@gmail.com>
Subject: Re: Issue with select statements, vertical bars?
Message-Id: <1157602271.236356.224580@b28g2000cwb.googlegroups.com>
snoopy_@excite.com wrote:
> Hello,
> I am trying to use DBI to perform a select statement, but it's
> choking with a format problem:
>
> ORA-00923: FROM keyword not found where expected (DBD ERROR:
> OCIStmtExecute/Describe)
>
> Could this be an issue with using vertical bars?
>
> Select statement is as follows:
>
> my $sql = qq{
>
> select 'user|' || up.user_name || '|' || up.base_db || '|' || up.dept
> || '|' || up.group_id
> from pcms_workset_info wsin, pcms_users_profile up
> where up.user_name = UPPER ('$user_name' )
> and up.privilege_level = 0
> minus select null from dual
>
> };
I not very clear to what you want, but why you use 'qq' and '||'
simple easy is work perfect:
my $somthing=do("SELECT * FROM tb_name");
or
my $pre_db1 = prepare("SELECT * FROM tbname WHERE colum=?");
my $pre_db2 = $pre_db1->execute(23);
I think it may help
------------------------------
Date: 6 Sep 2006 23:46:46 -0700
From: "Brian McCauley" <nobull67@gmail.com>
Subject: Re: Issue with select statements, vertical bars?
Message-Id: <1157611606.245667.236210@p79g2000cwp.googlegroups.com>
snoopy_@excite.com wrote:
> Hello,
> I am trying to use DBI to perform a select statement, but it's
> choking with a format problem:
>
> ORA-00923: FROM keyword not found where expected (DBD ERROR:
> OCIStmtExecute/Describe)
>
> Could this be an issue with using vertical bars?
>
> Select statement is as follows:
>
> my $sql = qq{
>
> select 'user|' || up.user_name || '|' || up.base_db || '|' || up.dept
> || '|' || up.group_id
> from pcms_workset_info wsin, pcms_users_profile up
> where up.user_name = UPPER ('$user_name' )
> and up.privilege_level = 0
> minus select null from dual
>
> };
Have you tried printing out the value of $sql and pasting it into your
database program's interactive shell or similar tool?
My personal preference is to keep the SQL in DBI queries as plain and
simple as possilble. (By "plain" I mean avoid dialect specific SQL like
'||' and 'minus' and omitting the 'as').
I would create an SQL view (or procedure) to do the concatenation or do
it in the Perl.
BTW why do you CROSS JOIN pcms_workset_info then not use it?
Also be aware that interpolating data strings into SQL is a very good
way of making sure you can break into your system should you ever need
to. (Unfortunately it also means so can anyone else).
------------------------------
Date: Thu, 7 Sep 2006 04:42:12 GMT
From: merlyn@stonehenge.com (Randal Schwartz)
Subject: new CPAN modules on Thu Sep 7 2006
Message-Id: <J57H2C.16Bp@zorch.sf-bay.org>
The following modules have recently been added to or updated in the
Comprehensive Perl Archive Network (CPAN). You can install them using the
instructions in the 'perlmodinstall' page included with your Perl
distribution.
Baseball-Sabermetrics-0.03
http://search.cpan.org/~victor/Baseball-Sabermetrics-0.03/
A Baseball Statistics Module
----
CGI-Application-Plugin-PageBuilder-0.95
http://search.cpan.org/~cmoore/CGI-Application-Plugin-PageBuilder-0.95/
Simplifies building pages with multiple templates.
----
CPAN-Reporter-0.14
http://search.cpan.org/~dagolden/CPAN-Reporter-0.14/
Provides Test::Reporter support for CPAN.pm
----
CPAN-Reporter-0.15
http://search.cpan.org/~dagolden/CPAN-Reporter-0.15/
Provides Test::Reporter support for CPAN.pm
----
CPAN-Search-Lite-0.76
http://search.cpan.org/~rkobes/CPAN-Search-Lite-0.76/
setup and maintain a searchable CPAN database
----
Chart-Scientific-0.16
http://search.cpan.org/~kester/Chart-Scientific-0.16/
Generate simple 2-D scientific plots with logging, errbars, etc.
----
Class-Component-Recipe-0.01_02
http://search.cpan.org/~phaylon/Class-Component-Recipe-0.01_02/
Dynamic Component Containers
----
CtCmd-1.05
http://search.cpan.org/~ratl/CtCmd-1.05/
Perl extension for Rational ClearCase
----
DBIx-DataModel-0.21
http://search.cpan.org/~dami/DBIx-DataModel-0.21/
Classes and UML-style Associations on top of DBI
----
Email-MIME-1.852
http://search.cpan.org/~rjbs/Email-MIME-1.852/
Easy MIME message parsing.
----
Email-Simple-1.990
http://search.cpan.org/~rjbs/Email-Simple-1.990/
Simple parsing of RFC2822 message format and headers
----
Exporter-5.59
http://search.cpan.org/~ferreira/Exporter-5.59/
Implements default import method for modules
----
File-Copy-Recursive-0.26
http://search.cpan.org/~dmuey/File-Copy-Recursive-0.26/
Perl extension for recursively copying files and directories
----
File-Copy-Recursive-0.27
http://search.cpan.org/~dmuey/File-Copy-Recursive-0.27/
Perl extension for recursively copying files and directories
----
File-Next-0.28
http://search.cpan.org/~petdance/File-Next-0.28/
File-finding iterator
----
FileUpload-Filename-0.02
http://search.cpan.org/~fmerges/FileUpload-Filename-0.02/
Return the name of an uploaded file
----
HTML-GenToc-2.31
http://search.cpan.org/~rubykat/HTML-GenToc-2.31/
Generate a Table of Contents for HTML documents.
----
HTTP-Async-0.02
http://search.cpan.org/~evdb/HTTP-Async-0.02/
process multiple HTTP requests in parallel without blocking.
----
Handel-0.99_10
http://search.cpan.org/~claco/Handel-0.99_10/
Simple commerce framework with AxKit/TT/Catalyst support
----
IPC-Cmd-0.25
http://search.cpan.org/~kane/IPC-Cmd-0.25/
finding and running system commands made easy
----
Image-ExifTool-6.36
http://search.cpan.org/~exiftool/Image-ExifTool-6.36/
Read and write meta information
----
Log-Dispatch-Configurator-YAML-0.02
http://search.cpan.org/~fmerges/Log-Dispatch-Configurator-YAML-0.02/
Configurator implementation with YAML
----
MIME-Lite-HTML-1.22
http://search.cpan.org/~alian/MIME-Lite-HTML-1.22/
Provide routine to transform a HTML page in a MIME-Lite mail
----
Module-CPANTS-Analyse-0.66
http://search.cpan.org/~domm/Module-CPANTS-Analyse-0.66/
Generate Kwalitee ratings for a distribution
----
POE-Component-Server-IRC-0.99_04
http://search.cpan.org/~bingos/POE-Component-Server-IRC-0.99_04/
a fully event-driven networkable IRC server daemon module.
----
PPM-Make-0.83
http://search.cpan.org/~rkobes/PPM-Make-0.83/
Make a ppm package from a CPAN distribution
----
Perl6-Say-0.07
http://search.cpan.org/~jkeenan/Perl6-Say-0.07/
print -- but no newline needed
----
Pod-SAX-HyperScope-0.01
http://search.cpan.org/~moconnor/Pod-SAX-HyperScope-0.01/
A POD to OPML convertor for HyperScope
----
Proc-PID-File-Fcntl-1.01
http://search.cpan.org/~jgmyers/Proc-PID-File-Fcntl-1.01/
Manage PID files using fcntl() locks
----
REST-Application-0.96
http://search.cpan.org/~moconnor/REST-Application-0.96/
A framework for building RESTful web-applications.
----
RT-TicketWhiteboard-1.7
http://search.cpan.org/~jesse/RT-TicketWhiteboard-1.7/
----
Rose-DB-0.725
http://search.cpan.org/~jsiracusa/Rose-DB-0.725/
A DBI wrapper and abstraction layer.
----
Rose-DB-Object-0.752
http://search.cpan.org/~jsiracusa/Rose-DB-Object-0.752/
Extensible, high performance RDBMS-OO mapper.
----
Rubric-0.142
http://search.cpan.org/~rjbs/Rubric-0.142/
a notes and bookmarks manager with tagging
----
SVK-Churn-0.04
http://search.cpan.org/~gugod/SVK-Churn-0.04/
----
Sub-ForceEval-0.99
http://search.cpan.org/~lembark/Sub-ForceEval-0.99/
runtime cluck if a dying subrutine is not eval-ed.
----
Template-Plugin-JSON-0.01
http://search.cpan.org/~nuffin/Template-Plugin-JSON-0.01/
Adds a .json vmethod for all TT values.
----
URPM-1.46
http://search.cpan.org/~rgarcia/URPM-1.46/
Manipulate RPM files and headers
----
WWW-RobotRules-MySQLCache-0.01
http://search.cpan.org/~apatwa/WWW-RobotRules-MySQLCache-0.01/
Perl extension for maintaining a robots.txt in a MySQL database
----
WWW-Yahoo-DrivingDirections-0.08
http://search.cpan.org/~kester/WWW-Yahoo-DrivingDirections-0.08/
Generate driving directions for multiple-stop trips in the United States, courtesy of maps.yahoo.com.
----
WebService-FreeDB-0.77
http://search.cpan.org/~hmersch/WebService-FreeDB-0.77/
retrieving entries from FreeDB by searching for keywords (artist,track,album,rest)
----
XML-Filter-EzPod-1.0
http://search.cpan.org/~msergeant/XML-Filter-EzPod-1.0/
A SAX filter (for Pod::SAX) that makes writing Pod easier.
----
XML-Filter-EzPod-1.1
http://search.cpan.org/~msergeant/XML-Filter-EzPod-1.1/
A SAX filter (for Pod::SAX) that makes writing Pod easier.
If you're an author of one of these modules, please submit a detailed
announcement to comp.lang.perl.announce, and we'll pass it along.
This message was generated by a Perl program described in my Linux
Magazine column, which can be found on-line (along with more than
200 other freely available past column articles) at
http://www.stonehenge.com/merlyn/LinuxMag/col82.html
print "Just another Perl hacker," # the original
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
------------------------------
Date: 7 Sep 2006 03:42:46 GMT
From: John Bokma <john@castleamber.com>
Subject: Re: Numerical sort (Schwartzian xform)
Message-Id: <Xns9836E70B64ABCcastleamber@130.133.1.4>
merlyn@stonehenge.com (Randal L. Schwartz) wrote:
>>>>>> "Jorge" == Jorge <awkster@yahoo.com> writes:
>
> Jorge> I pass the array to my schwartzian transform sub routine using
> this Jorge> call ...
>
> Jorge> my @sorted_array = &SchwartzianTransform(' ', ['1n', -1],
> @array);
>
> You don't like Sort::Fields (in the CPAN) for some reason?
Doesn't have your last name in the module name (or any of the methods [1])
:-D
[1] wild guess.
--
John Experienced Perl programmer: http://castleamber.com/
Perl help, tutorials, and examples: http://johnbokma.com/perl/
------------------------------
Date: Thu, 07 Sep 2006 00:24:58 -0400
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: Numerical sort (Schwartzian xform)
Message-Id: <x7u03kz4kl.fsf@mail.sysarch.com>
>>>>> "JB" == John Bokma <john@castleamber.com> writes:
JB> merlyn@stonehenge.com (Randal L. Schwartz) wrote:
>>>>>>> "Jorge" == Jorge <awkster@yahoo.com> writes:
>>
Jorge> I pass the array to my schwartzian transform sub routine using
>> this Jorge> call ...
>>
Jorge> my @sorted_array = &SchwartzianTransform(' ', ['1n', -1],
>> @array);
>>
>> You don't like Sort::Fields (in the CPAN) for some reason?
JB> Doesn't have your last name in the module name (or any of the
JB> methods [1]) :-D
neither does sort::maker. it uses ST for the key to select that sort
style. same for the GRT. :)
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
------------------------------
Date: 6 Sep 2006 23:55:17 -0700
From: "samasama" <bryan@worldspice.net>
Subject: Re: Problems detecting multiple clients
Message-Id: <1157612117.044376.279020@p79g2000cwp.googlegroups.com>
> It would probably make sense to have %ip_conns be permanently reversed,
> i.e. have the IP be the key and socket be the value (or the value could
> just be "1" or undef, since the socket part which is stored in that hash
> is never used anyway (and indeed probably can't be used--hash keys
> are stringifed and thus lose their magic.))
>
I had a "Oh yeah..." moment... One of the main reasons I'm keying by
$CLIENT is because $CLIENT will be unique every connection. If I were
to key by ip address, this may not be true, two connections from
127.0.0.1 will not get two seperate keys... AFAIK. I need it to be
unique every time, be able to create multiple keys for the same ip
address. So with that, keying by $CLIENT does the job I want.
Though, now I'm trying to figure out out how to remove a single
instance...
my $pid = waitpid(-1, WNOHANG); # Wait for children to die
foreach my $keys (keys %children) {
my $value = $children{$keys};
if ($pid == $keys) {
my %temp = reverse %ip_conns;
delete $temp{$value};
%ip_conns = reverse %temp;
}
}
This works perfectly for right now, by down the road I might want to
allow two connections from the same host at once. In this case I
believe I would need to delete only one instance of $value.
I just started thinking about that so... I'm sure the solution is
quite easy.
Perhaps I could key %ip_conns by $kidpid, hmmm, have to think about
that.
Anyway, just ranting : )
--
samasama
------------------------------
Date: 6 Sep 2006 19:07:09 -0700
From: "deadpickle" <deadpickle@gmail.com>
Subject: Re: time icrement based loop
Message-Id: <1157594828.881590.230580@h48g2000cwc.googlegroups.com>
Tad McClellan wrote:
> deadpickle <deadpickle@gmail.com> wrote:
>
> > I get a bunch of errors:
> > Use of uninitilized value in string eq/ne at
> > C:/PXPerl/lib/Net/FileShare.pm
>
>
> That is not an error message.
>
> It is a warning message.
>
> (BTW: An "error" is different from an "error message".)
>
>
> > I have no clue as to whats going on.
>
>
> You are using an undef value when you don't want to be.
>
Is there a way to make this value defined, i tried installing the
module Net::Fileshare withh activestate's PPM but I guess it did not
work.
------------------------------
Date: Thu, 07 Sep 2006 09:19:01 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: Ultimate programmer's reference - Quickref.org launches
Message-Id: <Xns98373617C439Basu1cornelledu@127.0.0.1>
"A. Sinan Unur" <1usa@llenroc.ude.invalid> wrote in
news:Xns9835C093274Aasu1cornelledu@127.0.0.1:
> John Bokma <john@castleamber.com> wrote in
> news:Xns9835B24714430castleamber@130.133.1.4:
>
>> "Robby Walker" <robby.walker@gmail.com> wrote:
>>
>>> I'm not claiming to create new Perl docs - just a place you can get
>>> Perl docs and whatever other docs you need in the same browser tab.
...
> At this point, the OP is stealing, or, at least attempting to steal
> bandwidth for commercial gain to himself. Regardless of legality, I
> consider such behavior immoral.
I should point out that he is now serving Perl documentation using his own
bandwidth.
Sinan
--
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://augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html
------------------------------
Date: Thu, 07 Sep 2006 01:55:35 GMT
From: axel@white-eagle.invalid.uk
Subject: Re: Using named constants in cases of a switch
Message-Id: <r_KLg.9302$cw.9027@fed1read03>
axel@white-eagle.invalid.uk wrote:
> Which makes Readonly a useful alternative:
Sorry, I forgot to mention the source of this which was something I read
by Randal Schwartz.
Axel
------------------------------
Date: Thu, 7 Sep 2006 07:11:05 +0100
From: "John" <john1949@yahoo.com>
Subject: Re: XM::Simple - counting tags
Message-Id: <AYSdnQhD4-BjJGLZRVnyiw@eclipse.net.uk>
Hi
Thanks Mumia. When you said *forcearray* I realised my mistake.
I had been looking at an XML schema all morning with < and > everywhere and
had forgotten
that the returned value from XML::Simple was a *hash*. Hence as Tad says, I
was thinking of
*tags* but meant elements. Once I realised it was a hash, it was, as Peter
says, *obvious*.
So for those following the thread the complete answer would be:
my $xml=new XML::Simple (ForceArray => 1, suppressempty => 1); # create
object
my $data=$xml->XMLin("<needed>$request</needed>"); # read XML string
my @emp=@{$data->{'city'}->[0]->{'firm'}->[0]->{'employee'}};
my $no=scalar(@emp);
Sometimes, when your mind is focussed in one direction it is difficult to
see the problem.
Thanks Tad and Danke Peter. (I need to add [0] since I need to forcearray
for all the data).
Regards
John
------------------------------
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 9696
***************************************