[11847] in Perl-Users-Digest
Perl-Users Digest, Issue: 5447 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Apr 22 00:07:38 1999
Date: Wed, 21 Apr 99 21:00:18 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Wed, 21 Apr 1999 Volume: 8 Number: 5447
Today's topics:
\s+ and ' ' in split <kin@symmetrycomm.com>
Re: \s+ and ' ' in split (Larry Rosler)
Re: cookies & perl (Abigail)
Re: cookies & perl (Abigail)
Re: FAQ 4.11: How do I find the current century or mill (Larry Rosler)
Re: FAQ 4.12: How can I compare two dates and find the (Larry Rosler)
Re: How to make an array name to be a variable? rbradlaw@my-dejanews.com
Re: how to merge? (Abigail)
Re: invoking by "fire and forget" <e_broyles@yahoo.com>
list range operator (..) problem <esser@home.com>
Re: list range operator (..) problem (Larry Rosler)
Re: Perl notation question? <rick.delaney@home.com>
Re: Personal Web Server and Perl (Tad McClellan)
Re: Personal Web Server and Perl <rjbyrd@webaccess.net>
Re: Personal Web Server and Perl <wyzelli@yahoo.com>
Prombles storing multidimensional array in a file telecafe@my-dejanews.com
Script to tidy/format a C file <myke98@my-dejanews.com>
Re: Script to tidy/format a C file (Larry Rosler)
Scripts - SNMP (C.P.T.)
Re: Sorting Hashes of Arrays.... <peter@berghold.net>
The Future of Tk? <eugened@istar.ca>
Re: The question about debug and design <xidicone@iname.com>
Re: The question about debug and design (Larry Rosler)
Re: Too many SIGCHLDs ? (Charles DeRykus)
Re: Verifying text in a string (Abigail)
Re: Verifying text in a string (Tad McClellan)
Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 22 Apr 1999 02:01:53 -0000
From: Kin Cho <kin@symmetrycomm.com>
Subject: \s+ and ' ' in split
Message-Id: <19990422020153.15009.qmail@nym.alias.net>
What's the difference between ' ' and \s+ when used in split?
In the following code, ' ' behaves as expected, but not \s+.
Why?
$l = ' a b c';
@f = split(/\s+/,$l);
print $f[0]; # $f[1] contains a!
@f = split(' ',$l);
print $f[0];
__END__
TIA,
-kin
perl -v:
This is perl, version 5.005_02 built for MSWin32-x86-object
Copyright 1987-1998, Larry Wall
Binary build 507 provided by ActiveState Tool Corp. http://www.ActiveState.com
Built 15:08:32 Nov 14 1998
------------------------------
Date: Wed, 21 Apr 1999 19:58:52 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: \s+ and ' ' in split
Message-Id: <MPG.118830429c7f512a989906@nntp.hpl.hp.com>
[Posted and a courtesy copy sent.]
In article <19990422020153.15009.qmail@nym.alias.net> on 22 Apr 1999
02:01:53 -0000, Kin Cho <kin@symmetrycomm.com> says...
> What's the difference between ' ' and \s+ when used in split?
> In the following code, ' ' behaves as expected, but not \s+.
> Why?
It may not behave as you expected, but it behaves as documented.
>
> $l = ' a b c';
> @f = split(/\s+/,$l);
> print $f[0]; # $f[1] contains a!
> @f = split(' ',$l);
> print $f[0];
Had you troubled to read the description of split() in perlfunc, you
would have come across the following sentence: "A split() on /\s+/ is
like a split(' ') except that any leading whitespace produces a null
first field."
That would have given you the answer faster and saved lots of bandwidth
around the world.
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: 22 Apr 1999 02:00:53 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: cookies & perl
Message-Id: <7flvsl$6mq$3@client2.news.psi.net>
Lars Plessmann (larsplessmann@gmx.de) wrote on MMLIX September MCMXCIII
in <URL:news:371E3EFD.5F0FD6DE@gmx.de>:
.. is it possible to read the cookies of a browser by perl?
.. if so, how can I do that? (larsplessmann@gmx.de)
Well, you first offer the browser some milk, and when it accepts it
and is off guard, you bang it on its head and steal its cookies.
Or you poke around in /dev/kmem.
But you may be lucky. Sometimes, some browsers, at some point, write
some cookies to some file, in some format. For some values of some.
Don't ask in this group the values of some, as that's not the topic
of this group. You can however, read the manul on how to read a file.
Abigail
--
sub f{sprintf$_[0],$_[1],$_[2]}print f('%c%s',74,f('%c%s',117,f('%c%s',115,f(
'%c%s',116,f('%c%s',32,f('%c%s',97,f('%c%s',0x6e,f('%c%s',111,f('%c%s',116,f(
'%c%s',104,f('%c%s',0x65,f('%c%s',114,f('%c%s',32,f('%c%s',80,f('%c%s',101,f(
'%c%s',114,f('%c%s',0x6c,f('%c%s',32,f('%c%s',0x48,f('%c%s',97,f('%c%s',99,f(
'%c%s',107,f('%c%s',101,f('%c%s',114,f('%c%s',10,)))))))))))))))))))))))))
------------------------------
Date: 22 Apr 1999 02:02:58 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: cookies & perl
Message-Id: <7fm00i$6mq$4@client2.news.psi.net>
David Cassell (cassell@mail.cor.epa.gov) wrote on MMLIX September
MCMXCIII in <URL:news:371E5BBB.65BD42AB@mail.cor.epa.gov>:
"" Lars Plessmann wrote:
"" >
"" > is it possible to read the cookies of a browser by perl?
"" > if so, how can I do that? (larsplessmann@gmx.de)
""
"" That said, you might be interested to know that the CGI.pm
"" module will do this and a lot of other nice stuff for you.
"" So will several other modules, all of which are available
"" at CPAN.
Oh really? I've my browser here, and I know it got a cookie. How do
I use CGI.pm to read that cookie? I thought CGI was for the _server_
side, not the client?
Abigail
--
perl -weprint\<\<EOT\; -eJust -eanother -ePerl -eHacker -eEOT
------------------------------
Date: Wed, 21 Apr 1999 19:47:44 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: FAQ 4.11: How do I find the current century or millennium?
Message-Id: <MPG.11882da96a36fbf5989905@nntp.hpl.hp.com>
[Posted and a courtesy copy sent.]
In article <371e7b72@cs.colorado.edu> on 21 Apr 1999 19:29:22 -0700, Tom
Christiansen <tchrist@mox.perl.com> says...
> In comp.lang.perl.misc,
> ada@fc.hp.com (Andrew Allen) writes:
> :: return int((((localtime(shift || time))[5] + 1999))/100);
> :: return 1+int((((localtime(shift || time))[5] + 1899))/1000);
> :
> :my simple brain finds the following easier to understand (removed a
> :redundant paren pair too):
> :
> : return int(((localtime(shift || time))[5] + 1900 + 99)/100);
> : return int(((localtime(shift || time))[5] + 1900 + 999)/1000);
>
> But that code is different. You just put us in the third
> millennium already. :-)
Methinks the code is the same. Move the 1 inside the numerator after
multiplying by 1000, add to 1899 = 2899; 1900 + 999 = 2899. And they
both return 2 for the millennium as expected.
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Wed, 21 Apr 1999 20:21:56 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: FAQ 4.12: How can I compare two dates and find the difference?
Message-Id: <MPG.118835abc4f00f7a989909@nntp.hpl.hp.com>
[Posted and a courtesy copy sent.]
In article <371e7af2@cs.colorado.edu> on 21 Apr 1999 19:27:14 -0700, Tom
Christiansen <perlfaq-suggestions@perl.com> says...
...
> How can I compare two dates and find the difference?
>
> If you're storing your dates as epoch seconds then simply subtract
> one from the other. If you've got a structured date (distinct year,
> day, month, hour, minute, seconds values) then use one of the
> Date::Manip and Date::Calc modules from CPAN.
That doesn't seem like the best approach at all. For accessibility,
simplicity, and efficiency, it would make much more sense to use either
timelocal or timegm (from the Time::Local module in the standard
distribution) to reduce structured dates to epoch seconds.
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Thu, 22 Apr 1999 03:02:38 GMT
From: rbradlaw@my-dejanews.com
Subject: Re: How to make an array name to be a variable?
Message-Id: <7fm3gd$dm4$1@nnrp1.dejanews.com>
In article <7flhop$tsd$1@nnrp1.dejanews.com>,
du_bing@my-dejanews.com wrote:
> Hi,
>
> I want an array name to be a variable. For example, in the following code,
> $array could be either 'test1' or 'test2' depending on the input to the code.
>
> %test1 = (one,1,two,2);
> %test2 = (three, 3, four, 4);
>
> foreach $key (keys %$array)
> {
> print "$key: $($array){$key}\n";
> ---------
> }
> }
>
> The underlined part gave me the syntax error? Any ideas?
> Thank you,
>
> Bing
>
> -----------== Posted via Deja News, The Discussion Network ==----------
> http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
>
although the previously posted responses are entertaining and maybe not
without merit, i will optimistically think you just got a typopraphical error
and really meant to type
print "$key: ${$array}{$key}\n";
(assuming, of course, that $array = \%test[1|2]
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: 22 Apr 1999 02:22:51 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: how to merge?
Message-Id: <7fm15r$6r3$1@client2.news.psi.net>
bing-du@tamu.edu (bing-du@tamu.edu) wrote on MMLIX September MCMXCIII in
<URL:news:7fl9gq$lt6$1@nnrp1.dejanews.com>:
;;
;; I know how to use 'split' to cut a string. How to merge all the elements (but
;; seperated by space) of a list?
You join() them.
Abigail
--
perl -MLWP::UserAgent -MHTML::TreeBuilder -MHTML::FormatText -wle'print +(
HTML::FormatText -> new -> format (HTML::TreeBuilder -> new -> parse (
LWP::UserAgent -> new -> request (HTTP::Request -> new ("GET",
"http://work.ucsd.edu:5141/cgi-bin/http_webster?isindex=perl")) -> content))
=~ /(.*\))[-\s]+Addition/s) [0]'
------------------------------
Date: Thu, 22 Apr 1999 03:09:23 GMT
From: e_broyles <e_broyles@yahoo.com>
Subject: Re: invoking by "fire and forget"
Message-Id: <7fm3t1$e1p$1@nnrp1.dejanews.com>
Andrea,
Thanks for your response. I think that I have tried this. I think that I
must reiterate exactly what I am trying to do.
I have an extensive perl program that I must run on another, remote server.
I only have access to it through ftp and, of course, WWW. I would like to be
able to hit a link on a page(with security of course) that would start a perl
program running on the server. This program takes quite a time to run. I
want there to be no output back to the browser, and I don't want the
processing to die if I disconnect from the internet or that page. This is
what started me down the road of dealing with processes. If I had more
access to the server (and could therefore run the program "c:\perl
myprog.pl") I would not be futzing around with the processes.
>From memory, I think I am running ActiveState Perl 5.04 something.
Again, thanks for your help!
In article <371d97cc.14360545@news.iol.it>,
aspinelli@ismes.it (Andrea LN Spinelli) wrote:
> On Mon, 19 Apr 1999 17:49:46 GMT, e_broyles <e_broyles@yahoo.com>
> wrote:
>
> >Does this mean that there is no way to get a child process that continues to
> >run even if the parent process dies or stops intentionally?
>
> I think you made several errors in you original post,
> (not quoting which perl are you using, not
> posting your code or a simplified version)
> but as I saw you being kicked in the face, I empathised
> with you and now I try to put this thread towards a constructive
> conclusion.
>
> I tried the following code (copied from the Win32::Process docs,
> with minor changes)
> ---file is q.pl---
>
> use Win32::Process;
>
> sub ErrorReport{
> print Win32::FormatMessage( Win32::GetLastError() );
> }
>
> Win32::Process::Create($ProcessObj,
> "c:\\windows\\notepad.exe",
> "notepad c:\\tmp\\q.pl",
> 0,
> NORMAL_PRIORITY_CLASS,
> ".")|| die ErrorReport();
>
> I tried it on my Win95 home machine, because I am ill at home, but
> I am absolutely sure it works on my office WinNT box.
>
> Now, if I launch this thing with
> perl q.pl
>
> I see notepad pop up on my desktop, then q.pl exits,
> and notepad continues to work. Now, his means, IMHO,
> that your question at the beginning of this post has a
> 'no' answer: you _can_ spawn a process which continues
> to run even after the father has died.
>
> Now, what is your _real_ problem? Since you did
> not post your code, I have only hypoteses:
>
> a. you tried using 'system', which is not absolutely what you
> need
> b. you used Win32::Process, with incorrect arguments.
>
> The incorrect argument is presumably the 5th. I cannot experiment
> here at home, but I suggest you to open the source code
> of win32::process (on my box it is in
> c:\bin\perl\site\lib\win32\process.pm) and
> see the list of constants towards the beginning (it
> starts with
>
> CREATE_DEFAULT_ERROR_MODE
> CREATE_NEW_CONSOLE
> CREATE_NEW_PROCESS_GROUP
> CREATE_NO_WINDOW
> ....
>
> Now you can experiment with those values (I
> think a good guess might be DETACHED_PROCESS)
>
> The, and this is the most important thing I ask you,
> _please_ post what you came out with on this group.
>
> See you
> Andrea
>
>
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Thu, 22 Apr 1999 02:33:18 GMT
From: "Marc Esser" <esser@home.com>
Subject: list range operator (..) problem
Message-Id: <OTvT2.2673$fY6.932@news.rdc1.sdca.home.com>
Hi folks,
please look at or run the following snippet of code:
@myarray = (1,2,3);
@myarray[0,1,2] = @myarray[2,1,0];
print "array 1: @myarray\n";
@myarray = (1,2,3);
@myarray[0..2] = @myarray[2..0];
print "array 2: @myarray\n";
According to the definition of .. this should print the
same thing in both cases, ie.
array 1: 3 2 1
array 2: 3 2 1
Instead, it prints:
array 1: 3 2 1
array 2:
The array has turned empty in the second case.
I have tried this with Perl 5.0005_03 for Win32 and with 5.004_04 on Linux .
Is there a simple and stupid explanation for this or does this also puzzle
you?
Thanks,
Marc
------------------------------
Date: Wed, 21 Apr 1999 20:13:14 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: list range operator (..) problem
Message-Id: <MPG.118833a1254a6a33989908@nntp.hpl.hp.com>
[Posted and a courtesy copy sent.]
In article <OTvT2.2673$fY6.932@news.rdc1.sdca.home.com> on Thu, 22 Apr
1999 02:33:18 GMT, Marc Esser <esser@home.com> says...
...
> @myarray = (1,2,3);
> @myarray[0,1,2] = @myarray[2,1,0];
> print "array 1: @myarray\n";
>
> @myarray = (1,2,3);
> @myarray[0..2] = @myarray[2..0];
> print "array 2: @myarray\n";
...
> The array has turned empty in the second case.
>
> I have tried this with Perl 5.0005_03 for Win32 and with 5.004_04 on Linux .
>
> Is there a simple and stupid explanation for this or does this also puzzle
> you?
It is simple; stupid is too subjective for comment. Not reading the
documentation may be stupid, though.
The second sentence under "Range Operators" in perlop: "In list
context, it returns an array of values counting (by ones) from the left
value to the right value." It counts by ones, not by minus-ones.
If you must do this, use
[ reverse 0 .. 2 ]
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Thu, 22 Apr 1999 03:00:55 GMT
From: Rick Delaney <rick.delaney@home.com>
Subject: Re: Perl notation question?
Message-Id: <371E9082.2D2319E7@home.com>
[posted & mailed]
David Cassell wrote:
>
> Perhaps the answer is:
> TIMTOWTSI - There Is More Than One Way To Spell It.
Probably.
> I prefer TIMTOWTDI, since the docs say it is supposed to be pronounced
> 'tim-toady'.
perldoc perl
The Perl motto is "There's more than one way to do it."
^^^^^^^
--
Rick Delaney
rick.delaney@home.com
------------------------------
Date: Wed, 21 Apr 1999 17:48:27 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Personal Web Server and Perl
Message-Id: <b3hlf7.eo6.ln@magna.metronet.com>
Mr. Pumpkin (pumpkin@nowhere.com) wrote:
: I have installed MS PWS on my computer and Perl 5 as well. The associations
: for both .cgi and .pl work fine (start perl when I double click). The web
: server is working fine, but when it attempts to run the cgi through a
: browser, it just say web contacted, waiting for for reply and hangs until it
: eventually gives up.
: Any ideas?
One really great idea would be to ask WWW questions in a
newsgroup that has some connection to WWW stuff.
This is not such a newsgroup.
We discuss Perl questions here.
Do you have a Perl question?
: better web server?
Perl does not have a "server"...
comp.infosystems.www.authoring.cgi
comp.infosystems.www.servers.ms-windows
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Wed, 21 Apr 1999 21:07:04 -0600
From: "Robert Byrd" <rjbyrd@webaccess.net>
Subject: Re: Personal Web Server and Perl
Message-Id: <371e74c1.0@news.webaccess.net>
To get CGI running, execute the Perl script located at
http://www.access.digex.net/~jurlwin/ -- download and execute the script
located under the section "Hints to get CGI under NT/95 running" to get CGI
running under Microsoft's Personal Web Server found in Option Pack 4.
Download and rename the iis_install.pl.txt to iis_install.pl and execute the
file (double click on iis_install.pl after installing ActivePerl) to update
your registry. Works great!
Rob...
Mr. Pumpkin wrote in message ...
>I have installed MS PWS on my computer and Perl 5 as well. The
associations
>for both .cgi and .pl work fine (start perl when I double click). The web
>server is working fine, but when it attempts to run the cgi through a
>browser, it just say web contacted, waiting for for reply and hangs until
it
>eventually gives up. Any ideas? better web server?
>
>Thanks,
>Forest
>
>
------------------------------
Date: Thu, 22 Apr 1999 13:29:39 +0930
From: "Wyzelli" <wyzelli@yahoo.com>
Subject: Re: Personal Web Server and Perl
Message-Id: <J8xT2.50$bD2.4772@vic.nntp.telstra.net>
This was a question about PWS Rob, not IIS
;^)
Wyzelli
------------------------------
Date: Thu, 22 Apr 1999 01:50:51 GMT
From: telecafe@my-dejanews.com
Subject: Prombles storing multidimensional array in a file
Message-Id: <7flv9q$a39$1@nnrp1.dejanews.com>
Now I would like to save a 2-D array as a file, to maintain the information
during the program execution and quit. The 2-D array only consists of 0 and
1, but I don't want to use vec, pack and unpack functions because of saving
execution time. I've tried DB_File and MLDBM modules to tie the array to
the file, but I couldn't get a satisfactory result.
What should I do to save 2-D array to a file, with the least effort?
Thanks in advance,
K Min
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Thu, 22 Apr 1999 02:34:05 GMT
From: Myke <myke98@my-dejanews.com>
Subject: Script to tidy/format a C file
Message-Id: <7fm1qt$c67$1@nnrp1.dejanews.com>
I've exhausted pretty much every avenue I could think of in searching for a
script which would tidy/format a C file. Maybe I've been looking in the wrong
places so I thought I'd ask here if anyone knew of such a thing (it doesn't
have to be a Perl script either).
If it doesn't exist then I may take this opportunity to learn Perl and write
the script myself. But before I do so I wanted to ask if such a script already
existed, and also, can Perl handle such a task?
--
m y k e
how ya gonna win when ya ain't right within?
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Wed, 21 Apr 1999 20:33:30 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Script to tidy/format a C file
Message-Id: <MPG.1188385b780f533e98990a@nntp.hpl.hp.com>
[Posted and a courtesy copy sent.]
In article <7fm1qt$c67$1@nnrp1.dejanews.com> on Thu, 22 Apr 1999
02:34:05 GMT, Myke <myke98@my-dejanews.com> says...
> I've exhausted pretty much every avenue I could think of in searching for a
> script which would tidy/format a C file. Maybe I've been looking in the wrong
> places so I thought I'd ask here if anyone knew of such a thing (it doesn't
> have to be a Perl script either).
The command `man 1 cb` on my HP-UX system produces this:
cb(1)
NAME
cb - C program beautifier, formatter
I don't know how widely distributed this program is, but it's been
around for decades. Long before Perl.
> If it doesn't exist then I may take this opportunity to learn Perl and write
> the script myself. But before I do so I wanted to ask if such a script already
> existed, and also, can Perl handle such a task?
Yes, of course it can. But why bother?
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Thu, 22 Apr 1999 03:23:48 GMT
From: cpt@mnsi.net (C.P.T.)
Subject: Scripts - SNMP
Message-Id: <924751428.352.40@news.remarQ.com>
Hello all.
I'm a beginner with Perl, and I have a few questions. I hope someone will help
me or point me in the right direction. (i.e. bookk, tutorial, examples)
Is it possbile to have a script that will poll certain hardware with SNMP
and then post on top of a graphic in a web page some sort of other graphic?
For exaample. If free mem = # and ping < # then it would put a green
circle on a graphic indicating everything is ok. I'd like to do this with
3 different colors, red, green and amber to indicate the status of the
equipment.
Is this feasible? I have a few scripts already that I can run to get SNMP
statistics that work, my problem is with posting data onto html. I'm using
ActivePerl and IIS4 on NT Worstation. I have Perl setup, running fine.
I'd appreciate any help anyone can offer.
Thanks,
Chris.
P.S. If you can please CC me.
------------------------------
Date: Thu, 22 Apr 1999 02:02:42 GMT
From: "Peter L. Berghold" <peter@berghold.net>
Subject: Re: Sorting Hashes of Arrays....
Message-Id: <371E8340.6B7673BC@berghold.net>
Anthony Baratta wrote:
> Howdy...
>
> Here is the data....ID, Name, Address, City (being pulled from an mSQL
> Database)
>
OK....
>
> What I am looking for is the best way to store this info in an Array,
> Hash, Hash of Arrays - whatever allows me to pull the data out ordered
> by City and Name.
>
I'll do some hand waving here... but hopefully you'll get the idea
<code>
@results=();
foreach $row(@query){ # loop through the query result
$data = {
id=>$row[0],
name=>$row[1],
address=>$row[2],
city=>$row[3]
}; # modify to suit your real life situation.
push @results,$data;
}
@results = sort { $a->{name} <=> $b->{name} } @results;
</code>
>
> Would I be better off using the 'order by' option with the SQL select
Personally that would be my preference. Let the engine do the work. Makes
your code a little tidier and your paying for the baggage of a SQL engine to
begin with. Take advantage of it.
--
-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Peter L. Berghold Peter@Berghold.Net
"Linux renders ships http://www.berghold.net
NT renders ships useless...." ICQ# 11455958
------------------------------
Date: Wed, 21 Apr 1999 23:23:59 -0400
From: Eugene Dragoev <eugened@istar.ca>
Subject: The Future of Tk?
Message-Id: <371E964F.C531C2A@istar.ca>
For programmers using languages other than Tcl.
I recently "discovered" the latest stable version of Tcl/Tk (8.05) and
must say that was quite impressed by the simplicity and ease of use of
Tk.
But I also found that while older versions of Tk were using lightweight
components (Some Java terminology :) the latest version is using native
components for things like scrollbars and buttons.
I don't want to say that this is bad for Tcl users but what about all
the other languages that use Tk? Isn't writting multiplatform GUI harder
using native components. I think Java made big step forward in
abandoning the native components and using lightweight ones in Swing.
Is there going to be any Tk implementation that will continue using
lightweight components?
What do you think?
Eugene
------------------------------
Date: Thu, 22 Apr 1999 12:23:20 +1100
From: Jussi Jumppanen <xidicone@iname.com>
Subject: Re: The question about debug and design
Message-Id: <371E7A08.75@iname.com>
Carfield Yim wrote:
> I am a starter of programming,
> I find I always have no idea how to design and I always debug by "try
> and error"
>
> How can I train my design
Takes some time to put you thoughts down on paper before actually
sitting
down to code. Try to desging you code to a particular style. For example
if
you want use a do top down type of desging aproach then try to break you
problem down into small functions using psuedo code and paper. As an
very simple example:
Main routine
begin
read in the records and store them somewhere (one function)
process the stored records (another function)
print the result produced (anaother function)
end
read function
begin
...
end
If you want to use an object oriented approach then try to identify the
objects and put these down on paper.
Now take you paper and start to write some code.
> and debug skill?
This is just practice and understanding the machine. For example don't
be scared to have a look at the assmebler output. This can sometimes
help when it comes to detecting problems.
Jussi Jumppanen
Author of: Zeus for Windows, Win32 (Brief, WordStar, Emacs) Text Editor
"The C/C++, Java, HTML, Pascal, Cobol, Fortran programmers text editor"
Home Page: http://ourworld.compuserve.com/homepages/jussi/
------------------------------
Date: Wed, 21 Apr 1999 20:05:17 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: The question about debug and design
Message-Id: <MPG.118831c2f7c54f81989907@nntp.hpl.hp.com>
In article <371E7A08.75@iname.com> on Thu, 22 Apr 1999 12:23:20 +1100,
Jussi Jumppanen <xidicone@iname.com> says...
...
> This is just practice and understanding the machine. For example don't
> be scared to have a look at the assmebler output. This can sometimes
> help when it comes to detecting problems.
Gosh, that would be fun for a Perl program. :-)
Maybe followups don't belong in the Perl newsgroup.
--
Larry Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Thu, 22 Apr 1999 02:17:36 GMT
From: ced@bcstec.ca.boeing.com (Charles DeRykus)
Subject: Re: Too many SIGCHLDs ?
Message-Id: <FAKJpC.3v4@news.boeing.com>
In article <371DA509.88550592@bilbo.iok.net>,
Dennis Wetzig <dennis@bilbo.iok.net> wrote:
>Hi,
>
>Look at the appended example code I wrote. I create children (which
>imediately exit) until fork fails for the first time (no more processes
>available). Then I run into an endless loop.
>
>I would expect that the signal handler would then catch all the
>SIGCHLDs, and by
>this I would get rid of all the zombies.
>
>This is not the case: Some of them I get rid of, but a lot just stays as
>zombies. No matter how long I wait.
>
>
>The only thing I could imagine, is that the Signalhandler gets confused
>whenever
>a SIG arrives while another one is currently processed. Is that
>possible?
>
>
>---- My code ----
>
>$SIG{CHLD}=sub { wait };
>
There's quite a bit that can go wrong with what you've
written. For instance, your C<wait> in the handler will
block and, if two children arrive in the interim, only
one will be reported.
A non-blocking waitpid(2) will be better:
use POSIX ":sys_wait_h";
$SIG{CHLD}=sub { 1 while waitpid(-1, WNOHANG) > 0};
or, with most modern OS's you can just say:
$SIG{CHLD} = 'IGNORE';
There's a really good explanation called "Avoiding Zombie
Processes" in the Perl Cookbook by T. Christiansen.
hth,
--
Charles DeRykus
------------------------------
Date: 22 Apr 1999 02:27:20 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Verifying text in a string
Message-Id: <7fm1e8$6r3$2@client2.news.psi.net>
Jukka Juslin (jtjuslin@cc.hut.fi) wrote on MMLIX September MCMXCIII in
<URL:news:371E1FF3.7D2A13D0@wannabe.mit.edu>:
-- jharmor@my-dejanews.com wrote:
-- >
-- > I am looking for an easy way to verify that the chars, in a three char string
-- > are only in the sets [A-Z] or [a-z] or [0-9] and contain no other chars i.e.
-- > (@.*&).
-- > The string was created by user input and I am trying to strip out non text
-- > chars.
--
-- The answer is quite obviously \W switch, for example:
-- $name =~ s/\W.*//;
That would remove every from the first non-alphaundernum onwards.
But that wasn't what was asked.
--
-- The \W searches for nonword characters, actually. You have to strip off
-- _ after that because it matches that also.
--
-- Anyway you should work harder by yourself - do not ask things like this
-- in news. You wont get nothing usefull done if you can't read the man
-- pages.
You should work harder yourself as well. This isn't the first time
today you answer a question incorrectly. Consider reading the man pages
yourself.
Abigail
--
perl -we 'print split /(?=(.*))/s => "Just another Perl Hacker\n";'
------------------------------
Date: Wed, 21 Apr 1999 17:45:40 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Verifying text in a string
Message-Id: <4uglf7.eo6.ln@magna.metronet.com>
jharmor@my-dejanews.com wrote:
: I am looking for an easy way to verify that the chars, in a three char string
: are only in the sets [A-Z] or [a-z] or [0-9] and contain no other chars i.e.
: (@.*&).
: The string was created by user input and I am trying to strip out non text
: chars.
Uhh, but @.*& _are_ text characters...
anyway,
print "bogus input\n" unless /^[a-zA-Z0-9]{3}$/;
or, if underscore is an OK character:
print "bogus input\n" unless /^\w{3}$/;
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: 12 Dec 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Special: Digest Administrivia (Last modified: 12 Dec 98)
Message-Id: <null>
Administrivia:
Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing.
]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body. Majordomo will then send you instructions on how to confirm your
]subscription. This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.
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.
To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.
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.
The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.
The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.
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 V8 Issue 5447
**************************************