[25529] in Perl-Users-Digest
Perl-Users Digest, Issue: 7773 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Feb 12 06:05:32 2005
Date: Sat, 12 Feb 2005 03:05:14 -0800 (PST)
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, 12 Feb 2005 Volume: 10 Number: 7773
Today's topics:
Re: Adding Form elements xhoster@gmail.com
Re: Adding From elements.... <tadmc@augustmail.com>
Re: Advice on converting hashed packages to pseudo-hash xhoster@gmail.com
Re: How to close a listening socket asynchronously xhoster@gmail.com
Re: Is there a more idiomatic way to do this? <amead@comcast.net>
Mac OS X Update -> module's man in / <news@chaos-net.de>
Re: new to group, need a temperature perl script. <1usa@llenroc.ude.invalid>
Re: new to group, need a temperature perl script. <lockster@gmail.com>
Re: new to group, need a temperature perl script. <spamtrap@dot-app.org>
Re: one more IP addr regexp <No_4@dsl.pipex.com>
Re: one more IP addr regexp <No_4@dsl.pipex.com>
Re: Piecewise fetching using perl dbi xhoster@gmail.com
Regular Expression help xsnslaine@gmail.com
Re: Regular Expression help <1usa@llenroc.ude.invalid>
Re: Regular Expression help <jurgenex@hotmail.com>
Re: Sorting a Multi-dimenional Array <toreau@gmail.com>
Re: string and pattern problem <abigail@abigail.nl>
Re: string and pattern problem <tadmc@augustmail.com>
string sort() <rem.rep@verizon.net>
Re: string sort() <noreply@gunnar.cc>
Re: string sort() <jurgenex@hotmail.com>
Re: track how many moves to sort an array? <abigail@abigail.nl>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 12 Feb 2005 00:48:09 GMT
From: xhoster@gmail.com
Subject: Re: Adding Form elements
Message-Id: <20050211194809.173$GX@newsreader.com>
dbmeyers23@yahoo.com wrote:
> All,
>
> I have a form with about 150 fields that I would like to have added
> together automatically and the value placed into a new variable.
You have that in the wrong order. Make a new variable, and use it to
add up the things you want to add up. I guess you could use
List::Util::sum along with map and grep to avoid having to predeclare your
newv variable, but that seems rather silly.
> Below, you will see my @list. Below that, I'm going through @list
You are not going through @list, you are going through @labels, whatever
that is.
> and
> only printing those values which have data (thanks to google.groups).
>
> What I would like to do now, and I'm struggling a bit to do is add
> these quantities together....so anywhere I see "addquantity", I would
> like to keep adding the values until done..then place them in a new
> variable. Any hints??
>
...
my $newvariable;
> for (@labels) {
>
> if ( $query->param( $$_[0] ) ) {
>
> print "$$_[1]: ", $query->param( $$_[0] ), "<br>";
> print INT_EMAIL "$$_[1]: ", $query->param( $$_[0] ), "\n";
$newvariable+=$$_[1] if $$_[0] =~ /addquantity/;
>
> }
> }
--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service $9.95/Month 30GB
------------------------------
Date: Fri, 11 Feb 2005 15:19:38 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Adding From elements....
Message-Id: <slrnd0q8ba.636.tadmc@magna.augustmail.com>
dbmeyers23@yahoo.com <dbmeyers23@yahoo.com> wrote:
> What I would like to do now, and I'm struggling a bit to do is add
> these quantities together
> Any hints??
Perl's addition operator is the plus sign (+).
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: 12 Feb 2005 00:17:47 GMT
From: xhoster@gmail.com
Subject: Re: Advice on converting hashed packages to pseudo-hashed packages
Message-Id: <20050211191747.323$t2@newsreader.com>
"Ian" <giblin@panix.com> wrote:
> <gulp> ... Thanks for the warning! It is a bit worrying that I was
> about to "upgrade" to a deprecated feature. I hope that I can
> future-proof the code under 5.6.1 as well as speed it up. I'm using
> perl 5.6.1 because it's the only one supported at my site. I hope there
> will be a new edition of Conway's "Object Oriented Perl" if there isn't
> one already. - Regards, Ian.
They probably wouldn't have speeded your program up noticably anyway.
Have you profiled it to see where it spends its time?
Xho
--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service $9.95/Month 30GB
------------------------------
Date: 12 Feb 2005 01:17:46 GMT
From: xhoster@gmail.com
Subject: Re: How to close a listening socket asynchronously
Message-Id: <20050211201746.440$v9@newsreader.com>
Franz Prilmeier <prilmeie@informatik.tu-muenchen.de> wrote:
> Hi,
>
> I want to write a simple SMTP server (As a side note with
> Net::SMTP::Server) for evaluating incoming mails. One of my objectives is
> having a proper server shutdown.
What do you mean by a "proper server shutdown"?
> I will try to argue on a code example:
Your code also doesn't tell us what you mean by a proper server shutdown.
Unless you mean that shutting down your server very second is proper, which
I highly doubt.
...
>
> A friend of mine already told me, that $server in the child might not the
> same object as $server in the parent thread.
I don't see why it wouldn't be. $socket was set before the fork.
> I want to be able to close a socket while it is listening (waiting for
> incoming connection via the accept call). In a different thread.
Perl doesn't to threads very well.
> And
> definitely not by killing the whole program. I want to be able to do this
> inside the same program.
Upon what event?
> I haven't been able to find any proper solutions
> (except connecting to the socket in the stop method - which is not what I
> want to do either).
By calling "accept", you are declaring that want to block until something
connects. If you don't want to block until something connects, don't
call "accept" until/unless you know someone is knocking on the door.
Stuff the $socket into an IO::Select object, then use can_read to see if
there is something trying to connect to $socket. (See the example given in
perldoc IO::Select).
Now that you are only checking in every now and then to see if anyone is
there, you are free to close the socket whenever you wish.
>
> To be short: Is there a clean way to close a socket while it is listening
> for incoming connections?
Xho
--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service $9.95/Month 30GB
------------------------------
Date: Fri, 11 Feb 2005 22:42:40 -0600
From: Alan Mead <amead@comcast.net>
Subject: Re: Is there a more idiomatic way to do this?
Message-Id: <pan.2005.02.12.04.42.39.792863@comcast.net>
On Thu, 10 Feb 2005 22:01:46 -0800, Steve May wrote:
> I suppose a hash might be more perlish:
>
> my %files = (
> 1 => 'filename1',
> 2 => 'filename2',
> };
>
> my $dataref = '';
>
> $files{$condition} and $dataref = get_data( $files{$condition} );
>
> $dataref or do_something_else;
Thanks to everyone for explaining the issue and offering suggestions. I
think I like the use of a list for integers but actually my conditions
would be better represented by strings so this hash idea is a good one.
-Alan
--
Help out our research and get a free
personality profile:
http://www.web-data-collection.org
------------------------------
Date: Sat, 12 Feb 2005 11:56:09 +0100
From: Martin Kissner <news@chaos-net.de>
Subject: Mac OS X Update -> module's man in /
Message-Id: <slrnd0ro69.1cp.news@maki.homeunix.net>
Hello together,
I have updated my Mac OS X from 10.3.7 to 10.3.8 last night.
Today was surprised to find a director /man in / , which contains two
subdirs man1 and man3. Inside there are about 50 files which seem to be
related to modules, which I have installed.
Filenames are for example DBI.pm , DBD//mysql.3pm or
DBI//ProfileDumper//Apache.3pm.
Inside the files there is only manual text, but no perl code.
Now my main question is: Where do these files/directories have to go to?
And if anyone knows: Why did this happen; is this common?
Thanks in advance
Martin
--
perl -e 'print 7.74.117.115.116.11.32.13.97.110.111.116.104.101.114.11
.32.13.112.101.114.108.11.32.13.104.97.99.107.101.114.10.7'
------------------------------
Date: Fri, 11 Feb 2005 23:53:34 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: new to group, need a temperature perl script.
Message-Id: <Xns95FAC0303140Casu1cornelledu@127.0.0.1>
Lambik <lambik@kieffer.nl> wrote in news:373uuvF58hgkfU1@individual.net:
> scupper79 wrote:
>
>> I access this through Outlook Express, where are the guidelines?
>>
>
> That's your first mistake
>
It is not as bad as using Google groups. The posting guidelines are posted
here several times a month. I don't know how you could have missed them if
you had observed the common sense rule of reading the group a little
before posting.
Of course, you can also find the web site where they are posted. Google's
search engine would be helpful if you were so inclined.
Sinan
------------------------------
Date: 11 Feb 2005 22:50:20 -0800
From: "Matthew Lock" <lockster@gmail.com>
Subject: Re: new to group, need a temperature perl script.
Message-Id: <1108191020.859614.142130@l41g2000cwc.googlegroups.com>
A. Sinan Unur wrote:
> It is not as bad as using Google groups.
Just wondering what's so bad about Google Groups?
Matthew
------------------------------
Date: Sat, 12 Feb 2005 02:05:20 -0500
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: new to group, need a temperature perl script.
Message-Id: <8OudnRwskfIvN5DfRVn-3g@adelphia.com>
Matthew Lock wrote:
> Just wondering what's so bad about Google Groups?
There seem to be two major gripes:
First, postings coming from GG have all their indentation removed. Very
annoying at best - for some folks, like the Python group(s), it's fatal.
And second, Google's interface makes it less than obvious that a reply
should include the relevant parts of the message it's in response to.
Also, although I can't conclusively link it to GG, in my opinion the noise
level has gone up, and the collective IQ here down, since Google launched
their new interface. Something about it just seems to attract trolls and
idiots in droves - I don't know why.
I'm just about (but not quite) to the point of just killfiling anything with
google.com in the header.
sherm--
--
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org
------------------------------
Date: Fri, 11 Feb 2005 23:14:04 +0000
From: Big and Blue <No_4@dsl.pipex.com>
Subject: Re: one more IP addr regexp
Message-Id: <xIednWz09eehoZDfRVnytQ@pipex.net>
Abigail wrote:
>
> So, "localhost" is a valid IP address as well?
No - it's a(n interface) name.
That's the difference between the "a" and the "n" side in inet_aton()
and inet_ntoa().
--
Just because I've written it doesn't mean that
either you or I have to believe it.
------------------------------
Date: Fri, 11 Feb 2005 23:16:23 +0000
From: Big and Blue <No_4@dsl.pipex.com>
Subject: Re: one more IP addr regexp
Message-Id: <xIednW_09edaoZDfRVnytQ@pipex.net>
Chris Mattern wrote:
>
> No, because it doesn't work if the process can't do name resolution.
> The numbers B&B gave will (in most implementation of telnet, at least).
Indeed, IIRC the RFC says they should. (Well, it might actually say
MAY, SHOULD or MUST, but I haven't read it recently :-)).
--
Just because I've written it doesn't mean that
either you or I have to believe it.
------------------------------
Date: 12 Feb 2005 00:37:19 GMT
From: xhoster@gmail.com
Subject: Re: Piecewise fetching using perl dbi
Message-Id: <20050211193719.648$Eo@newsreader.com>
"JonL" <landenburger@msn.com> wrote:
> We have some data in an Oracle database stored as a Long Raw.
> We can extract it using DBI, but only up to a certain length.
> Once we get above 20MB we start getting error messsages ora-1062 which
> comes out as
> 01062, 00000, "unable to allocate memory for define buffer"
> // *Cause: Exceeded the maximum buffer size for current plaform
> // *Action: Use piecewise fetch with a smaller buffer size
> // *Action: Use a client application linked with V8 (or higher)
> libraries.60
>
> I've looked up piecwise fetching and inserting in various Oracle
> documents but I dont think DBI supports it. Any Ideas?
Maybe upgrade your client application linked with V8 or higher.
Or switch from long raw to blob. I know I've gone bigger than 20MB using
blobs.
Or use the "substr" sql function to select only chunks of the data.
Xho
--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service $9.95/Month 30GB
------------------------------
Date: 11 Feb 2005 15:44:27 -0800
From: xsnslaine@gmail.com
Subject: Regular Expression help
Message-Id: <1108165467.643557.298410@g14g2000cwa.googlegroups.com>
Im new to Regular Expressions and have something really really really
simple (i assume to do. but i just cant get the results i want
what i want to do is validate height in feet and inches
for example
5'9 or 5'9" would be acceptable
"/[0-9]\.'?[0-12]/"
that is what have have so far .... but it dont work :(
could someone explain where i have gone wrong? and how to do it?
Thanks in advance.....
Dan.
------------------------------
Date: Sat, 12 Feb 2005 00:05:35 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: Regular Expression help
Message-Id: <Xns95FAC239CB6CEasu1cornelledu@127.0.0.1>
xsnslaine@gmail.com wrote in news:1108165467.643557.298410
@g14g2000cwa.googlegroups.com:
> Im new to Regular Expressions and have something really really really
> simple (i assume to do. but i just cant get the results i want
>
> what i want to do is validate height in feet and inches
>
> for example
>
> 5'9 or 5'9" would be acceptable
>
> "/[0-9]\.'?[0-12]/"
Why the \. then?
>
> that is what have have so far .... but it dont work :(
>
> could someone explain where i have gone wrong? and how to do it?
What you have done wrong is to try to use something without
understanding it. From perldoc perlreref:
[...] Matches any one of the characters contained within the brackets
So, the second character class above says match 0, 1 or 2.
It might be preferable in this case to first capture the potential feet
and inches and then do a validity check following a successful match.
Keeps the regex simple.
use strict;
use warnings;
my @s = (q{5'9"}, q{5'9});
for (@s) {
if( /(\d+)'(\d+)"?/ ) {
my $feet = $1;
my $inches = $2;
# bounds check
print "$feet feet $inches inches\n";
}
}
__END__
------------------------------
Date: Sat, 12 Feb 2005 00:09:05 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: Regular Expression help
Message-Id: <BObPd.2382$uc.706@trnddc01>
xsnslaine@gmail.com wrote:
> Im new to Regular Expressions and have something really really really
> simple (i assume to do. but i just cant get the results i want
>
> what i want to do is validate height in feet and inches
>
> for example
>
> 5'9 or 5'9" would be acceptable
>
> "/[0-9]\.'?[0-12]/"
Ok, trying to translate back into plain English. This should match
- a single digit between 0 and 9 (i.e. any digit, you could have use \d
instead for better readability)
- followed by a literal dot
- followed by at most one apostroph
- followed by a single digit between 0 and 1 or the digit 2 (that would have
been easier to write as [012] or [0-2])
> that is what have have so far .... but it dont work :(
> could someone explain where i have gone wrong? and how to do it?
I don't know for sure what you mean by "it don't work" but at least the
literal dot in the RE looks kind of suspicious.
And I don't know either what you consider a valid height versus an invalid
height. Therefore I cannot tell how to fix it.
jue
------------------------------
Date: Sat, 12 Feb 2005 01:29:32 +0100
From: Tore Aursand <toreau@gmail.com>
Subject: Re: Sorting a Multi-dimenional Array
Message-Id: <M5cPd.8582$IW4.199675@news2.e.nsc.no>
jason_mandal@yahoo.com wrote:
> With something I meant nothing. The data I am trying to sort has been
> listed. I tried to seek help from perldoc, and I am able to sort for
> integers, but when the numbers are exponential I have no clear idea of
> how to use the sort function.
> Use of <=> and cmp does not help as they do not understand exponential
> values. Correct me if I am wrong
Try this one:
#!/usr/bin/perl
#
use strict;
use warnings;
use Data::Dumper;
my @data;
while ( <DATA> ) {
chomp;
my @fields = split( /\s+/, $_, 4 );
push( @data, \@fields );
}
my @sorted = sort {
$b->[3] <=> $a->[3]
} @data;
print Dumper( \@sorted );
__DATA__
Name1 123e-10 34e-5 -1.0567e-8
Name2 23e-10 4e-5 1.0567e-8
Name3 13e-10 3e-5 -1.0567e-9
Name4 12e-10 33e-5 .0011
Name5 123e-10 34e-5 -1.0567e-8
--
Tore Aursand <tore@aursand.no>
"The road to hell is full of good intentions." (Bruce Dickinson)
------------------------------
Date: 11 Feb 2005 23:07:34 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: string and pattern problem
Message-Id: <slrnd0qelm.g2.abigail@alexandra.abigail.nl>
Tajana (tajana@removeingko.com) wrote on MMMMCLXXXIII September MCMXCIII
in <URL:news:420d133a$1@news.s5.net>:
\\ > @@ Form for telephone number is XXX/XXXX-XXX or XXX/XXX-XXX or
\\ XX/XXXX-XXX, so
\\ > @@ I have problem with different number format.X is for numeric
\\ > @@ 3/4-3 or 3/3-3 or 2/4-3 number character
\\ >
\\ > m![0-9]{2}(?:[0-9]/[0-9]?|/[0-9])[0-9]{3}-[0-9]{3}!g;
\\
\\ Thanks!
\\ That is nice. Work, but I still don understand how that work.
\\ I have some more possible format for phone number.
\\ So new definition for phone number is something made by: [0-9], "/" and "-".
\\ I don now length of phone number. (it possible that have more that one "/"
\\ or "-")
\\ Eg:
\\ 0047/367/5645-555
\\ 47/366/5555-5555-15
\\ are also a phone number.
Let's see:
- You post the same message twice.
- You send a stealth Cc to your reply.
- You ask a question, and if there's a reply, you say "yeah, but what
I really want is..."
That's three strikes. You're out.
*PLONK*
Abigail
--
srand 123456;$-=rand$_--=>@[[$-,$_]=@[[$_,$-]for(reverse+1..(@[=split
//=>"IGrACVGQ\x02GJCWVhP\x02PL\x02jNMP"));print+(map{$_^q^"^}@[),"\n"
------------------------------
Date: Fri, 11 Feb 2005 18:11:04 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: string and pattern problem
Message-Id: <slrnd0qico.6u9.tadmc@magna.augustmail.com>
Tajana <tajana@removeingko.com> wrote:
> I have some more possible format for phone number.
> So new definition for phone number is
And after we fix that, you'll come back with a 3rd added thing?
Then a 4th?
Then a 5th?
You will use up all of your coupons quickly by changing the
specification _after_ the implementation has been completed.
Think about your problem more before you ask others to
volunteer their time helping to solve it.
Learn as much as you can about regular expressions:
perldoc perlrequick
perldoc perlretut
perldoc perlre
then ask a coherant question about the particular aspect that
you are having trouble understanding.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Sat, 12 Feb 2005 03:14:54 GMT
From: "Chris" <rem.rep@verizon.net>
Subject: string sort()
Message-Id: <OwePd.18317$ya6.3314@trndny01>
How could i possibly sort this my $mystring = "this"
and make it look like my $mystring = "hist"
------------------------------
Date: Sat, 12 Feb 2005 04:24:28 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: string sort()
Message-Id: <375c7qF52h4qvU1@individual.net>
Chris wrote:
> How could i possibly sort this my $mystring = "this"
> and make it look like my $mystring = "hist"
$mystring = join '', sort split //, $mystring;
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: Sat, 12 Feb 2005 06:06:32 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: string sort()
Message-Id: <I1hPd.21193$wc.16151@trnddc07>
Chris wrote:
> How could i possibly sort this my $mystring = "this"
> and make it look like my $mystring = "hist"
Guessing here (one single example is not a very good way to describe the
expected behaviour of a generic algorithm), but do you want to sort the
characters of a string? In that case:
- perldoc -f split
- perldoc -f sort
- perldoc -f join
jue
------------------------------
Date: 11 Feb 2005 23:16:23 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: track how many moves to sort an array?
Message-Id: <slrnd0qf65.g2.abigail@alexandra.abigail.nl>
Scott Bryce (sbryce@scottbryce.com) wrote on MMMMCLXXXII September
MCMXCIII in <URL:news:UY-dneNtNqHziZHfRVn-hg@comcast.com>:
-- Jürgen Exner wrote:
--
-- > Not quite. You are counting how often two elements are compared.
--
-- # Perhaps this is what the OP wanted?
-- @list = sort {$count ++ if $a gt $b; $a cmp $b} @list;
No. That still counts compares, not moves. There's no way to count
the number of moves from within Perl.
Abigail
--
srand 123456;$-=rand$_--=>@[[$-,$_]=@[[$_,$-]for(reverse+1..(@[=split
//=>"IGrACVGQ\x02GJCWVhP\x02PL\x02jNMP"));print+(map{$_^q^"^}@[),"\n"
------------------------------
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 7773
***************************************