[28167] in Perl-Users-Digest
Perl-Users Digest, Issue: 9531 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Jul 27 14:05:59 2006
Date: Thu, 27 Jul 2006 11:05:06 -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, 27 Jul 2006 Volume: 10 Number: 9531
Today's topics:
Re: counting number of uniques in a multidimensional ar <tzz@lifelogs.com>
Re: DirHandle : the sort is different on Windows and on <someone@example.com>
Re: DirHandle : the sort is different on Windows and on <josef.moellers@fujitsu-siemens.com>
Re: DNS with bind9 sucks, what is an easier tool for fu <tzz@lifelogs.com>
Re: garbage collector <bik.mido@tiscalinet.it>
Re: garbage collector <1usa@llenroc.ude.invalid>
Re: garbage collector xhoster@gmail.com
Re: How to find all files in a directory with a specifi <rvtol+news@isolution.nl>
Re: How to use threads to parallelise 4 different DB co <mol10metal@hotmail.com>
Re: How to use threads to parallelise 4 different DB co xhoster@gmail.com
Re: How to use threads to parallelise 4 different DB co <rvtol+news@isolution.nl>
Perl 6 <whoami@whereami.com>
Re: Perl 6 <sigzero@gmail.com>
Re: Perl 6 <DJStunks@gmail.com>
Re: Perl 6 <bik.mido@tiscalinet.it>
Re: Please confirm bug in SHLOMIF > Error-0.17 > Error <dbasch@yahoo.com>
Re: Please confirm bug in SHLOMIF > Error-0.17 > Error <1usa@llenroc.ude.invalid>
Re: Questions about (non-blocking) sockets xhoster@gmail.com
Re: Script to find unique words in a document <vilmos@soti.ca>
Re: Script to find unique words in a document <rvtol+news@isolution.nl>
Scripting for file transfer maxwelton@my-deja.com
Re: Scripting for file transfer <mritty@gmail.com>
Re: Scripting for file transfer <1usa@llenroc.ude.invalid>
Text descriptions of signal codes? allenjo5@mail.northgrum.com
Re: Text descriptions of signal codes? <1usa@llenroc.ude.invalid>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 27 Jul 2006 11:30:28 -0400
From: Ted Zlatanov <tzz@lifelogs.com>
Subject: Re: counting number of uniques in a multidimensional array column
Message-Id: <g69zmevf4kr.fsf@CN1374059D0130.kendall.corp.akamai.com>
On 26 Jul 2006, benmorrow@tiscali.co.uk wrote:
> Quoth Ted Zlatanov <tzz@lifelogs.com>:
>
>> Interestingly, length(undef) is also 0, which makes Tad's length()
>> test eliminate undef values as well. For extra credit and fun, figure
>> out why length(undef) is 0
>
> ... with a warning...
Hey, I'm training the OP to compete in fwp contests :)
Ted
------------------------------
Date: Thu, 27 Jul 2006 13:13:06 GMT
From: "John W. Krahn" <someone@example.com>
Subject: Re: DirHandle : the sort is different on Windows and on Linux
Message-Id: <CZ2yg.167265$S61.63133@edtnps90>
thierry.torret@st.com wrote:
> I use a old Perl script using Dirhandle but the sort is different on
> Windows and on Linux
>
> $dh = new DirHandle($test) || return;
> while ($OneFile = $dh->read()) {
>
> In Windows the directory and files are sorted by name : it is OK
> but on Linux there are sorted in order of directory
> creation/modification date but we want it by name.
The DirHandle module is just an OO wrapper around Perl's built-in
opendir/readdir/rewinddir/closedir functions and these functions do not do any
sorting. If you want the results sorted you will have to do it yourself.
perldoc -f sort
John
--
use Perl;
program
fulfillment
------------------------------
Date: Thu, 27 Jul 2006 15:23:13 +0200
From: Josef Moellers <josef.moellers@fujitsu-siemens.com>
Subject: Re: DirHandle : the sort is different on Windows and on Linux
Message-Id: <eaaev9$btl$1@nntp.fujitsu-siemens.com>
John W. Krahn wrote:
> thierry.torret@st.com wrote:
>=20
>>I use a old Perl script using Dirhandle but the sort is different on
>>Windows and on Linux
>>
>> $dh =3D new DirHandle($test) || return;
>> while ($OneFile =3D $dh->read()) {
>>
>>In Windows the directory and files are sorted by name : it is OK
>>but on Linux there are sorted in order of directory
>>creation/modification date but we want it by name.
>=20
>=20
> The DirHandle module is just an OO wrapper around Perl's built-in
> opendir/readdir/rewinddir/closedir functions and these functions do not=
do any
> sorting. If you want the results sorted you will have to do it yoursel=
f.
>=20
> perldoc -f sort
Which is sensible, because if you don't want them sorted, how would you=20
un-sort 'em?
--=20
Josef M=F6llers (Pinguinpfleger bei FSC)
If failure had no penalty success would not be a prize
-- T. Pratchett
------------------------------
Date: Thu, 27 Jul 2006 11:31:41 -0400
From: Ted Zlatanov <tzz@lifelogs.com>
Subject: Re: DNS with bind9 sucks, what is an easier tool for full DNS?
Message-Id: <g69vepjf4iq.fsf@CN1374059D0130.kendall.corp.akamai.com>
On 26 Jul 2006, sqrex@poczta.fm wrote:
> In my opinion djbdns i very good replacment. It has modular
> construction so i.e. u don`t need to run full dns to have only caching
> function and it`s more secure.
>
> gavino napisal(a):
>> anyone?
What does it have to do with Perl, though?
Ted
------------------------------
Date: 27 Jul 2006 15:43:50 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: garbage collector
Message-Id: <o4ghc2db60q3cmokli6u7tb52auc497ae2@4ax.com>
On 27 Jul 2006 02:32:16 -0700, "Michael.F123@gmail.com"
<Michael.F123@gmail.com> wrote:
>> Sure, I know exactly why. It's because your program has a logic error.
>
>I think i use only 2 objects: the socket object the thread object. The
>socket object i delete when the client close the connection and after i
>close the connection the function end, so the thread ends also.
Then, again looking at your code, it seems that there must be another
error other than the one on line 17.
Michele
--
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
.'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,
------------------------------
Date: Thu, 27 Jul 2006 15:44:28 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: garbage collector
Message-Id: <Xns980D77888EF1Aasu1cornelledu@127.0.0.1>
Michele Dondi <bik.mido@tiscalinet.it> wrote in
news:o4ghc2db60q3cmokli6u7tb52auc497ae2@4ax.com:
> On 27 Jul 2006 02:32:16 -0700, "Michael.F123@gmail.com"
> <Michael.F123@gmail.com> wrote:
>
>>> Sure, I know exactly why. It's because your program has a logic
>>> error.
>>
>>I think i use only 2 objects: the socket object the thread object. The
>>socket object i delete when the client close the connection and after
>>i close the connection the function end, so the thread ends also.
>
> Then, again looking at your code, it seems that there must be another
> error other than the one on line 17.
C'mon Michele, the error is always on line 42, even if there is no line
42. Let's not break with tradition ;-))
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: 27 Jul 2006 15:56:40 GMT
From: xhoster@gmail.com
Subject: Re: garbage collector
Message-Id: <20060727120331.391$ig@newsreader.com>
"Michael.F123@gmail.com" <Michael.F123@gmail.com> wrote:
> usenet@DavidFilmer.com wrote:
> > Michael.F123@gmail.com wrote:
> > > Do you have any ideea why tje garbage collector
> > > do not delete the objects afther the thread is finished?
> >
> > Sure, I know exactly why. It's because your program has a logic error.
>
> I think i use only 2 objects:
If you showed us what you actually do, then we would be able to tell you if
you think right.
> the socket object the thread object. The
> socket object i delete when the client close the connection and after i
> close the connection the function end, so the thread ends also.
Are you ever going to post some real code, or are we just going to keep
shooting randomly into the night?
5.8.0 has some memory leaks with threads which 5.8.8 doesn't.
Xho
--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service $9.95/Month 30GB
------------------------------
Date: Thu, 27 Jul 2006 15:11:14 +0200
From: "Dr.Ruud" <rvtol+news@isolution.nl>
Subject: Re: How to find all files in a directory with a specific mtime
Message-Id: <eaal49.tg.1@news.isolution.nl>
schms schreef:
> I have to write a perl program which finds all files in a directory
> with mtime (modification time)
>
> of "today - 8 days" ( e.g. today is: 27.7.06, -8 days is: 19.7.06, so
> the file's modification
#!/usr/bin/perl
use strict ;
use warnings ;
use IO::All ;
my $path = "$ENV{HOME}/dev/perl" ;
printf "%s%8d%3d %s\n"
, $_->uid, $_->size, -M $_->name, $_->filename
for sort {$b->mtime <=> $a->mtime}
io($path)->filter( sub
{
my $m = -M $_->name ;
8 <= $m and $m <= 9
})->all_files ;
--
Affijn, Ruud
"Gewoon is een tijger."
------------------------------
Date: 27 Jul 2006 06:53:33 -0700
From: "Nick of course" <mol10metal@hotmail.com>
Subject: Re: How to use threads to parallelise 4 different DB connections?
Message-Id: <1154008413.237219.176520@75g2000cwc.googlegroups.com>
anju wrote:
> Hi ,
>
> My script is making connection to the four databases one by one and
> writing the output to a single excelsheet. But there being huge
> records, its taking too much time ( 4 hours), which is not acceptable.
>
> So I need to synchronise the process so that the connection is made to
> all the 4 DBs at one time and they run parallely.
>
> I tried using Perl threads/ ithreads for the same but its giving
> problem, like handles can't be shared , use clone() method etc. etc.
>
> Can you please advice how can I do the same?
>
> Please reply ASAP.
>
> Many Thanks in advance.
>
> Regards,
> Anju
I'm assuming that the excessive time taken is due to database access
and/or intermediate processing - there is no way it can take 4 hours to
write to a spreadsheet; they just don't get that big. Use four
separate processes (not threads) running in parallel that write to
intermediate files (maybe use Storable for efficiency) then a final
process to write the spreadsheet. As a solution, it is a lot simpler
and more robust than using threads.
------------------------------
Date: 27 Jul 2006 16:08:03 GMT
From: xhoster@gmail.com
Subject: Re: How to use threads to parallelise 4 different DB connections?
Message-Id: <20060727121454.292$ql@newsreader.com>
"anju" <go4anju@gmail.com> wrote:
> Hi ,
>
> My script is making connection to the four databases one by one and
> writing the output to a single excelsheet. But there being huge
> records, its taking too much time ( 4 hours), which is not acceptable.
How can one Excel spreadsheet hold 4 hours worth of records? That just
doesn't sound plausible for a decently tuned query. This suggests you
probably should spend more time tuning your database/sql and less time
tuning your perl.
> So I need to synchronise the process so that the connection is made to
> all the 4 DBs at one time and they run parallely.
Why not just use 4 programs which run simultanously and dump into temp
files, and a 5th program which combines these files into one final one?
> I tried using Perl threads/ ithreads for the same but its giving
> problem, like handles can't be shared , use clone() method etc. etc.
If you showed me real code with the real errors it produces, maybe I could
help. If you don't, the chances are much less that I can.
> Can you please advice how can I do the same?
>
> Please reply ASAP.
We are not paid consultants. Treating us as if we were is likely to
engender ill-will.
Xho
--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service $9.95/Month 30GB
------------------------------
Date: Thu, 27 Jul 2006 18:38:26 +0200
From: "Dr.Ruud" <rvtol+news@isolution.nl>
Subject: Re: How to use threads to parallelise 4 different DB connections?
Message-Id: <eab190.17c.1@news.isolution.nl>
anju schreef:
> Please reply ASAP.
Right after your donation:
http://donate.perl-foundation.org/index.pl?node=Fund+Drive+Details&selfund=2
http://donate.perl-foundation.org/index.pl?node=Contribution%20FAQ
--
Affijn, Ruud
"Gewoon is een tijger."
------------------------------
Date: Thu, 27 Jul 2006 15:25:08 +0100
From: "IanW" <whoami@whereami.com>
Subject: Perl 6
Message-Id: <eaaic4$5tp$1@south.jnrs.ja.net>
How is this progressing - anyone know when it's due to be released?
Ian
------------------------------
Date: 27 Jul 2006 08:04:21 -0700
From: "Robert Hicks" <sigzero@gmail.com>
Subject: Re: Perl 6
Message-Id: <1154012661.910849.55830@b28g2000cwb.googlegroups.com>
IanW wrote:
> How is this progressing - anyone know when it's due to be released?
>
> Ian
It is progressing...
Sometime around Christmas (not sure what year though)...
: )
Robert
------------------------------
Date: 27 Jul 2006 09:02:15 -0700
From: "DJ Stunks" <DJStunks@gmail.com>
Subject: Re: Perl 6
Message-Id: <1154016134.922742.100330@i42g2000cwa.googlegroups.com>
IanW wrote:
> How is this progressing - anyone know when it's due to be released?
you can watch this blog http://pugs.blogs.com/pugs/
or this feed http://planetsix.perl.org/rss20.xml
if you're really curious.
-jp
------------------------------
Date: 27 Jul 2006 20:02:04 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: Perl 6
Message-Id: <kqvhc25s46pjf8k2m4tc1dftpcg42bntq8@4ax.com>
On 27 Jul 2006 08:04:21 -0700, "Robert Hicks" <sigzero@gmail.com>
wrote:
>Sometime around Christmas (not sure what year though)...
Or, as uri would say, for some definition of Christmas...
Michele
--
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
.'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,
------------------------------
Date: 27 Jul 2006 10:11:47 -0700
From: "Derek Basch" <dbasch@yahoo.com>
Subject: Re: Please confirm bug in SHLOMIF > Error-0.17 > Error
Message-Id: <1154020307.415955.44210@h48g2000cwc.googlegroups.com>
Thanks for the help. I am sorry I didn't expand my examples enough. I
certainly wasn't hoping to find a bug but rather trying to figure out
something that had been "bugging" me for many hours. I will submit this
to CPAN.
Thanks,
Derek Basch
------------------------------
Date: Thu, 27 Jul 2006 17:25:07 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: Please confirm bug in SHLOMIF > Error-0.17 > Error
Message-Id: <Xns980D889908BDasu1cornelledu@127.0.0.1>
"Derek Basch" <dbasch@yahoo.com> wrote in news:1154020307.415955.44210
@h48g2000cwc.googlegroups.com:
> Thanks for the help. I am sorry I didn't expand my examples enough. I
> certainly wasn't hoping to find a bug but rather trying to figure out
> something that had been "bugging" me for many hours. I will submit this
> to CPAN.
It's OK. Mine was a gut reaction: In my mind, you got tossed in with a
group of people whose first instinct is yell "bug" whenever something does
not work the way they expect it to. Your explanation focused on something
that was not a problem at all, so I reacted strongly before I investigated
the problem myself.
I am glad you are reporting the bug, as I have not had a chance yet.
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: 27 Jul 2006 16:37:53 GMT
From: xhoster@gmail.com
Subject: Re: Questions about (non-blocking) sockets
Message-Id: <20060727124444.530$GC@newsreader.com>
Holger <spam.trap.never.read@mailinator.com> wrote:
> On 24 Jul 2006 23:06:33 GMT, xhoster@gmail.com wrote:
> > Holger <spam.trap.never.read@mailinator.com> wrote:
>
> > > my $socket = IO::Socket::INET->new( PeerAddr => $RemoteHost,
> > > PeerPort => $RemotePort )
> > > or die "Could not connect to $RemoteHost:$RemotePort: $@\n";
> > > my $select = IO::Select->new( $socket );
> > > while ( 1 ) {
> > > if ( $select->can_read( $timeout ) ) {
> > > unless ( defined $socket->recv( $data, 1028 ) ) {
> > > break;
> > > }
> > > else {
> > > # process received $data
> > > }
> > > }
> > > # do stuff, send data
> >
> > You might want the "send data" to be inside the else. Do you really
> > need to send data to the other every $timeout seconds, even if the
> > other side hasn't yet responded to your previous queries?
>
> As mentioned above I'd like to be able to send commands independently
> from the server sending data. Perhaps, I will insert code to send
> waiting data in both places.
There are two risks for deadlock here if your print to the socket in a
blocking (and even more so blocking and buffered) way, but they depend on
the unknown behavior of the other end (which I'll call the server). Since
the server seems to have two streams of output, one in reponse to the
client and one autonomous stream, how does it interweave them and are they
blocking or not? If the server prints the autonomous stream in a blocking
way, then it is possible that a big slug of autonomous data after your code
passes the recv and/or timeout but before your code finishes "do stuff;
send data". Then you might block waiting for server to read the data you
are trying to send, and thus you will not doing any "recv"ing; while the
server is blocked waiting for you to recv the autonomous data, refusing to
read more commands from you until you read form it. If your commands are
small and you only send a command after receiving a reply to the previous
command and the volume of autonomous data is low and evenly spread, this
risk is low. But if your commands are large, or you send many of them
asynchronously (which you probably are if you send after a timeout, in
addition to sending after a successful read), or the autonomous data comes
in large chunks, the risk is increased.
Consider what happens if the server does send autonomous data unblockingly.
What would it do if you just could never keep up with it? It would have to
buffer that unsent data internally, and the internal buffer could grow
without bound. Is that a risk the implementer of the server would likely
take? The implementer probably took some steps to avoid thus, but whether
that would be to use blocking, or to drop overflowing data, or just abort,
I don't know.
Second, even if the server sends autonomous data without blocking, does
it also send responsive data without blocking? It is quite plausible that
the server will only read as much from your socket as it needs to get one
complete command, and will then not read anymore until you process that
command and *you read all the results of that command*. So again, you will
block sending another command, while it blocks waiting for you to read the
output of the previous command, you have deadlock.
So in short, if you don't know how the server handles its data, you might
want to consider making the "send data" part in a nonblocking way using
select and syswrite rather than print. Of course, it depends on your
paranoia/laziness trade off.
Xho
--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service $9.95/Month 30GB
------------------------------
Date: 27 Jul 2006 09:07:56 -0700
From: Vilmos Soti <vilmos@soti.ca>
Subject: Re: Script to find unique words in a document
Message-Id: <lqmzavrpyb.fsf@vilmos.msmri.medicine.ubc.ca>
"Dr.Ruud" <rvtol+news@isolution.nl> writes:
> Mike schreef:
>
>> I have a need to establish a lexicon for a surgical environment. I
>> have approximately 20,000,000 lines of text from which I need to
>> determine unique "words". For the time-being, a "word" is
>> space-delimited (excluding punctuation, etc). I have done some
>> searching, but don't see anything obvious as far as pre-existing
>> scripts for doing this, but figure such a beast must have been created
>> before. Would anyone have any suggestions? I can create a single file
>> and read from that file.
>
> No Perl required.
>
> If you put each word on its own line, for instance by using 'tr' to
> replace each space and other word separating character by a \n, then the
> file becomes usable for 'sort -u' or 'sort | uniq'.
This is also how I would do except one problem. The OP mentioned
that he has approx. 20 million lines of text. If we suppose that
each line has 10-15 words, then we have 200-300 million lines to
sort. That can easily be 1 GB. Sort will be very slow on that.
Vilmos
------------------------------
Date: Thu, 27 Jul 2006 18:49:28 +0200
From: "Dr.Ruud" <rvtol+news@isolution.nl>
Subject: Re: Script to find unique words in a document
Message-Id: <eab1tr.1hc.1@news.isolution.nl>
Vilmos Soti schreef:
> [tr, sort]
> 1 GB. Sort will be very slow on that.
sort is quite fast. And it can work with presorted files, see the -m
option.
--
Affijn, Ruud
"Gewoon is een tijger."
------------------------------
Date: 27 Jul 2006 10:23:08 -0700
From: maxwelton@my-deja.com
Subject: Scripting for file transfer
Message-Id: <1154020988.321723.102240@h48g2000cwc.googlegroups.com>
I have the following in a csh script. This is run on a remote system
and the
goal is to allow a user on a client to tar and gzip files and download
them to
their system. All I get is streamed data to the browser. Any help
would
be appreciated.
# ! /bin/csh
echo "Content-description: File Transfer'\n"
echo "'Content-type: application/x-gzip\n'"
echo "Content-disposition: attachment; filename=\"site.tar.gz\"\n";
# < do some file redirection in here ->
tar cf - * | gzip -c
#end
The interesting thing is if I do:
tar cf - * | gzip -c > site.tar.gz
then the file is able to be unzipped and untarred and it is all good.
I think my problem is somewhere in those 'content' headers. I can
also try :
tar zcf - * | cat
and this streams the data to the browser as well.
------------------------------
Date: 27 Jul 2006 10:25:02 -0700
From: "Paul Lalli" <mritty@gmail.com>
Subject: Re: Scripting for file transfer
Message-Id: <1154021102.873977.261600@p79g2000cwp.googlegroups.com>
maxwel...@my-deja.com wrote:
> I have the following in a csh script.
Why was this cross-posted to a Perl newsgroup? There is no Perl
content here at all.
Thank you, however, for at least not multi-posting it...
Paul Lalli
------------------------------
Date: Thu, 27 Jul 2006 17:26:18 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: Scripting for file transfer
Message-Id: <Xns980D88CC0FABBasu1cornelledu@127.0.0.1>
maxwelton@my-deja.com wrote in news:1154020988.321723.102240
@h48g2000cwc.googlegroups.com:
> I have the following in a csh script.
And you are posting here why?
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: 27 Jul 2006 09:11:52 -0700
From: allenjo5@mail.northgrum.com
Subject: Text descriptions of signal codes?
Message-Id: <1154016712.413067.215330@m79g2000cwm.googlegroups.com>
Is there as easy a way to get the textual description of a process
signal code in perl as there is to get the textual description of a
system call error code? For instance, for an errno of 24, just set $!
to 24 and use it as a string:
$ perl -le '$!=24; print $!'
The process file table is full.
Is there something equivalent for getting the text meaning of signal
code 24 (SIGXCPU) without having to parse signal.h? Yeah I can do
that readily enough, but was expecting perl to provide an easier
method. So far, I haven't found the trick.
------------------------------
Date: Thu, 27 Jul 2006 16:34:59 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: Text descriptions of signal codes?
Message-Id: <Xns980D80196327asu1cornelledu@127.0.0.1>
allenjo5@mail.northgrum.com wrote in news:1154016712.413067.215330
@m79g2000cwm.googlegroups.com:
> Is there as easy a way to get the textual description of a process
> signal code in perl as there is to get the textual description of a
> system call error code? For instance, for an errno of 24, just set $!
> to 24 and use it as a string:
>
> $ perl -le '$!=24; print $!'
> The process file table is full.
>
> Is there something equivalent for getting the text meaning of signal
> code 24 (SIGXCPU) without having to parse signal.h? Yeah I can do
> that readily enough, but was expecting perl to provide an easier
> method. So far, I haven't found the trick.
Check out the following elements in %Config:
sig_count
sig_name
sig_name_init
sig_num
sig_init
#!/usr/bin/perl
use strict;
use warnings;
use Config;
use List::MoreUtils 'first_index';
my $sig_idx = first_index { $_ == 24 } split / /, $Config{sig_num};
if ( $sig_idx >= 0 ) {
my @sig_name = split / /, $Config{sig_name};
print $sig_name[$sig_idx], "\n";
}
__END__
--
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: 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 9531
***************************************