[18607] in Perl-Users-Digest
Perl-Users Digest, Issue: 775 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Apr 26 18:11:34 2001
Date: Thu, 26 Apr 2001 15:10:17 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <988323017-v10-i775@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Thu, 26 Apr 2001 Volume: 10 Number: 775
Today's topics:
Re: oop bless problem nobull@mail.com
Re: oop bless problem <jasonh@colubs.com>
Re: operators: != vs. ne, strange behaviour <comdog@panix.com>
perl certification <todd@designsouth.net>
Re: perl certification <uri@sysarch.com>
Re: perl certification (Greg Bacon)
Re: perl certification <root@novastar.dtdns.net>
Perl embeded on tcl scripts <root@novastar.dtdns.net>
Re: Perl embeded on tcl scripts <root@novastar.dtdns.net>
Re: Problem in Netscape with CGI Headers <andras@mortgagestats.com>
Re: Procmail Help <elijah@workspot.net>
Re: Procmail Help (Johan Vromans)
Re: re-sizing a GIF image on the fly <Jonathan.L.Ericson@jpl.nasa.gov>
Re: re-sizing GIF images on the fly (Anno Siegel)
Re: Regular expression for zip code (Anno Siegel)
Re: Regular expression for zip code (Craig Berry)
Re: Regular expression for zip code <ren@tivoli.com>
Re: Regular expression for zip code <ren@tivoli.com>
Re: Regular expression for zip code (Craig Berry)
Re: Regular expression for zip code <juex@deja.com>
Re: run by click in linux <joe+usenet@sunstarsys.com>
Re: s///g count <martin@djernaes.net>
Re: s///g count (Anno Siegel)
Re: s///g count <martin@djernaes.net>
Re: s///g count <bart.lateur@skynet.be>
Re: s///g count (Anno Siegel)
Separate syslog file? (Pat Traynor)
Re: SGI IRIX fork() syscall: child process doesn't term (Matthew Black)
Re: SGI IRIX fork() syscall: child process doesn't term (Matthew Black)
Single character reads on sockets <djmarcus@ex-pressnet.com>
Re: Sockets, Time-outs, and Alarms nobull@mail.com
split and array problem <hpya78@postoffice.pacbell.net>
Re: split and array problem <bart.lateur@skynet.be>
Re: US$50 prize for hash failure from 'delete' inside a <dan@tuatha.sidhe.org>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 26 Apr 2001 19:05:33 +0100
From: nobull@mail.com
Subject: Re: oop bless problem
Message-Id: <u9elufiljm.fsf@wcl-l.bham.ac.uk>
Please don't top-post.
Anno has already asked you nicely to to obey the rules of on-line good
manners "Netiquette".
You persistantly refuse to act with good manners. Are you are an
equally rude and arrogant person in meatspace too or is it just on the
net?
[jeopardectomy]
"Jason Hurst" <jasonh@colubs.com> writes:
>
> "Anno Siegel" <anno4000@lublin.zrz.tu-berlin.de> wrote in message
> news:9c7nrt$p8p$1@mamenchi.zrz.TU-Berlin.DE...
> > According to Jason Hurst <jasonh@colubs.com>:
> > > no, sorry, I'm trying to extend cgi.pm. i.e, I'm using it as my super
> > > class.
> > I'll just throw a demo script at you that demonstrates how
> > to inherit from CGI. It still doesn't bless anything explicitly.
> Have you taken a look at the script I'm doing? (which was
> previously given a link to in my first posting:
> http://www.colubs.com/saveStateDB.pm)
If you hadn't made a mess of the thread, maybe he wouldn't have been
so confused.
Your code contains:
my $self = new CGI;
bless ($self, $class);
The normal Perl idiom is:
my $self = $class->SUPER::new;
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Thu, 26 Apr 2001 13:27:36 -0700
From: "Jason Hurst" <jasonh@colubs.com>
Subject: Re: oop bless problem
Message-Id: <3ae884b6$0$140@wodc7nh1.news.uu.net>
Sorry if i offended anyone. i guess i don't understand what top posting is.
(unless thats something that this program is doing automatcialy that i don't
know about...) I did try all your examples and i couldn't get them to work.
Thanks to Ren for expaining things, that made sence. Thank you for your
help and once again, sorry for any ofince that i have quite oviosly caused.
------------------------------
Date: Thu, 26 Apr 2001 15:28:41 -0400
From: brian d foy <comdog@panix.com>
Subject: Re: operators: != vs. ne, strange behaviour
Message-Id: <comdog-62DADA.15284126042001@news.panix.com>
In article <slrn9egilh.fu0.eins@www42.t-offline.de>, eins@durchnull.de
wrote:
> > perhaps you should see earlier posts, and also identify the operating
> > system and version of Perl that you use if you post again. it would
> > be even better for you to try your claims on a variety of platforms.
>
> Hereby done. I use Linux (SuSE 7.1) and the included perl.
>
> perl -V displays:
>
> Summary of my perl5 (revision 5.0 version 6 subversion 0) configuration:
> Platform:
> osname=linux, osvers=2.4.0, archname=i586-linux
> And, since there was no answer, what does
>
> print ((-1) ** 0.5);
>
> do on your computer? Do you get some illegal value? -2147483648? 0? an
> error?
there was an answer. read backwards in the thread. since *BSD doesn't
think NaN is anything special if treats it as any other string. the
documented Perl string to number conversion occurs.
please try to keep up.
--
brian d foy <comdog@panix.com>
------------------------------
Date: Thu, 26 Apr 2001 18:35:49 GMT
From: "Todd Smith" <todd@designsouth.net>
Subject: perl certification
Message-Id: <9UZF6.29457$U4.6389179@news1.rdc1.tn.home.com>
Is there a Perl certification course that any employer actually cares about?
------------------------------
Date: Thu, 26 Apr 2001 18:51:32 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: perl certification
Message-Id: <x7lmonh4u7.fsf@home.sysarch.com>
>>>>> "TS" == Todd Smith <todd@designsouth.net> writes:
TS> Is there a Perl certification course that any employer actually
TS> cares about?
sure. pay me $1000 and i will mail you a perl certificate. you can show
it to any employer and impress the hell out of them.
DISCLAIMER:
i am not responsible for your work load or your being fired afterwards.
uri
--
Uri Guttman --------- uri@sysarch.com ---------- http://www.sysarch.com
SYStems ARCHitecture and Stem Development ------ http://www.stemsystems.com
Learn Advanced Object Oriented Perl from Damian Conway - Boston, July 10-11
Class and Registration info: http://www.sysarch.com/perl/OOP_class.html
------------------------------
Date: Thu, 26 Apr 2001 19:32:51 -0000
From: gbacon@HiWAAY.net (Greg Bacon)
Subject: Re: perl certification
Message-Id: <tegtv3i08m3d2f@corp.supernews.com>
In article <9UZF6.29457$U4.6389179@news1.rdc1.tn.home.com>,
Todd Smith <todd@designsouth.net> wrote:
: Is there a Perl certification course that any employer actually cares
: about?
Why? Are you certifiable or something?
Greg
--
Recently I saw a promotion where for each gun you handed in, you got two
tickets to an LA Clippers game. Now that doesn't work out too well because
after watching the Clippers you want to kill yourself, and you don't have a
gun. It is literally an O Henry story waiting to be written. --Dennis Miller
------------------------------
Date: Fri, 27 Apr 2001 00:32:05 +0300
From: "novastar" <root@novastar.dtdns.net>
Subject: Re: perl certification
Message-Id: <9ca44g$guf$1@usenet.otenet.gr>
Try to avoid this certification game if it is possible. I find it somehow
dirty, because if you get one then you are trapped. You have to give all
these exams every 6 months to be updated and not kicked out from your boss.
That is the bottom line. Ok and lets say that you get your certification,
and the next, and the next+1, but how long can you stand this race ?
"Todd Smith" <todd@designsouth.net> wrote in message
news:9UZF6.29457$U4.6389179@news1.rdc1.tn.home.com...
> Is there a Perl certification course that any employer actually cares
about?
>
>
------------------------------
Date: Fri, 27 Apr 2001 00:57:39 +0300
From: "novastar" <root@novastar.dtdns.net>
Subject: Perl embeded on tcl scripts
Message-Id: <9ca5ke$hgl$1@usenet.otenet.gr>
I have some system tools (windows) writen in perl that must be given to
operators but on a gui version . My first thought was start learning tcl. I
found some info for embeding java code to tcl but not for perl . Is there
any faq or tutorial around explaining the interaction between tcl and perl ?
Thanks in Advanced.
------------------------------
Date: Fri, 27 Apr 2001 01:04:01 +0300
From: "novastar" <root@novastar.dtdns.net>
Subject: Re: Perl embeded on tcl scripts
Message-Id: <9ca60c$hmi$1@usenet.otenet.gr>
oups, just saw the message "FAQ 3.13: How can I use X or Tk with Perl?"
bellow, sorry ...
"novastar" <root@novastar.dtdns.net> wrote in message
news:9ca5ke$hgl$1@usenet.otenet.gr...
> I have some system tools (windows) writen in perl that must be given to
> operators but on a gui version . My first thought was start learning tcl.
I
> found some info for embeding java code to tcl but not for perl . Is there
> any faq or tutorial around explaining the interaction between tcl and perl
?
> Thanks in Advanced.
>
>
------------------------------
Date: Thu, 26 Apr 2001 14:04:51 -0400
From: Andras Malatinszky <andras@mortgagestats.com>
Subject: Re: Problem in Netscape with CGI Headers
Message-Id: <3AE86343.A61CBCFC@mortgagestats.com>
ros@ros.com wrote:
> I have a script that writes to a database and presents itself again to
> ask for more data. It works perfectly in explorer, but navigator is
> much less permissive with headers and only gives me a 404 asking for
> my /cgi-bin/ root
>
> The script is as follows:
>
> &readfile;
> $q=new CGI;
> print $q->start_html(),
> $externalfilereadbefore,
> $q->end_html();
> $nombre=$q->param('name');
> if($nombre){
> &writetodatabase;
> }
> sub ...
>
> And I can't work it out. Any helping hand?
> Thanks in advance
> David
Well, there are a number of problems with your script:
there's no shebang line, which, depending on your OS, could be a problem,
you are creating a CGI object but neglected to use CGI before that,
readfile is undefined,
$externalfilereadbefore is undefined, which in itself is not a problem,
but it makes for a rather uninteresting output,
writetodatabase is undefined,
"..." is not a legal identifier for your subroutine on the last line of
the script,
even if you had a valid name for your subroutine, you would probably want
it to have some code.
Is it possible that there is, in fact, more to your script? Why don't you
share it with us?
------------------------------
Date: 26 Apr 2001 18:06:49 GMT
From: Eli the Bearded <elijah@workspot.net>
Subject: Re: Procmail Help
Message-Id: <eli$0104261403@qz.little-neck.ny.us>
In comp.lang.perl.misc, John Smith <j2lab@my-deja.com> wrote:
> I know this is a Perl newsgroup but I'm having some problems with
> Procmail. I'm trying to pass information from my mail header to a Perl
> script. I am trying to pass the Subject and From information. If there
> is another place I should post this, please let me know.
comp.mail.misc deals with lots of procmail questions. But
have you read the procmailex(1) man page?
To extract certain headers from a mail and put them into
environment variables you can use any of the following
constructs:
[snip answer so that you will read the docs]
From there perl can see them in %ENV.
Elijah
------
there is also the procmail mailing list, see the manpage for info
------------------------------
Date: 26 Apr 2001 20:15:58 +0200
From: JVromans@Squirrel.nl (Johan Vromans)
Subject: Re: Procmail Help
Message-Id: <m2vgnrv869.fsf@phoenix.squirrel.nl>
John Smith <j2lab@my-deja.com> writes:
> I know this is a Perl newsgroup but I'm having some problems with
> Procmail. I'm trying to pass information from my mail header to a Perl
> script. I am trying to pass the Subject and From information. If there
> is another place I should post this, please let me know.
http://search.cpan.org/search?mode=module&query=Mail%3A%3AProcmail
-- Johan
------------------------------
Date: 26 Apr 2001 21:27:26 +0000
From: Jon Ericson <Jonathan.L.Ericson@jpl.nasa.gov>
Subject: Re: re-sizing a GIF image on the fly
Message-Id: <86pudz1hdt.fsf@jon_ericson.jpl.nasa.gov>
Andrew Boswell <graham@dragroup.com> writes:
> I want to write a Perl script that examines a GIF file to determine the
> image size (width and height in pixels), then creates a thumbnail of it
> on the fly. Writing the script poses few problems, but how do you
> determine the size of a GIF image? I have downloaded the CompuServe
> GIF89a Spec but that doesn't seem to help much. I know that binary files
> are not meant to be read by humans, only computers, so how and with what
> do I read a (binary) GIF file on the fly, and extract the information I
> want?
Have you tried CPAN?
Jon
------------------------------
Date: 26 Apr 2001 20:03:55 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: re-sizing GIF images on the fly
Message-Id: <9c9uvb$fca$4@mamenchi.zrz.TU-Berlin.DE>
According to Andrew Boswell <graham@dragroup.com>:
> ...then creates a thumbnail of it on the fly. ...
Animal tormentor! What will they think of next?
Anno
------------------------------
Date: 26 Apr 2001 19:31:10 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Regular expression for zip code
Message-Id: <9c9t1u$fca$2@mamenchi.zrz.TU-Berlin.DE>
According to BarryK <notmyrealemail@fake.com>:
> I want to create a regular expression that will replace any legitimate zip
> code in either five digit format or 5-4 digit format with something.
>
> The following regular expression does not work!
>
> s< (\b\d{5}\b) | (\b\d{5}-\d{4}\b) > <X>x;
>
> From the number "12345-1234", it will return "X-1234".
>
> Any ideas?
Why, yes. The first alternative matches and gets replaced. You
probably didn't expect a word boundary between a digit and "-" but
there is one. Swap the alternatives.
Anno
------------------------------
Date: Thu, 26 Apr 2001 19:36:44 -0000
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Regular expression for zip code
Message-Id: <tegu6cn6ge6g8b@corp.supernews.com>
BarryK (notmyrealemail@fake.com) wrote:
: I want to create a regular expression that will replace any legitimate zip
: code in either five digit format or 5-4 digit format with something.
:
: The following regular expression does not work!
:
: s< (\b\d{5}\b) | (\b\d{5}-\d{4}\b) > <X>x;
:
: From the number "12345-1234", it will return "X-1234".
That's because the first alternative is tried and matches successfully.
: Any ideas?
s/\b\d{5}(?:-\d{4})\b/X/;
--
| Craig Berry - http://www.cinenet.net/~cberry/
--*-- "When the going gets weird, the weird turn pro."
| - Hunter S. Thompson
------------------------------
Date: 26 Apr 2001 13:11:51 -0500
From: Ren Maddox <ren@tivoli.com>
Subject: Re: Regular expression for zip code
Message-Id: <m3n193ttso.fsf@dhcp9-172.support.tivoli.com>
On Thu, 26 Apr 2001, sharding@ccbill.com wrote:
> "BarryK" <notmyrealemail@fake.com> wrote in message
> news:65YF6.28957$U4.6334726@news1.rdc1.tn.home.com...
>>
>> The following regular expression does not work!
>>
>> s< (\b\d{5}\b) | (\b\d{5}-\d{4}\b) > <X>x;
>>
>> From the number "12345-1234", it will return "X-1234".
>
> This expression will work:
>
> s/\b\d{5}(-\d{4})*\b/X/g;
>
> If you take each piece of your original expression, they work
> separately. I am *guessing* that since the operation is an OR, the
> first part matches and the second part never gets evaluated, thus
> producing the results you are seeing.
Yes. Which also means that swapping the expressions will work:
s< (\b\d{5}-\d{4}\b) | (\b\d{5}\b) > <X>x;
Also, depending on your exact need you are probably better off just
using a single set of capturing parens around the entire "|" expression
(and the "\b"-s can be moved outside of the expression):
s< \b (\d{5}-\d{4} | \d{5}) \b > <X>x;
Of course, Shay's suggestion, with a slight modification for capturing
parens, plus a fix to prevent things like 12345-1234-1234, is probably
better:
s< \b ( \d{5} (?: -\d{4} )? ) \b > <X>x;
Finally, all of these fail -- in my opinion -- to properly account for
the fact that "-" adjacent to a digit is a word boundary, so they
change "123-12345-123" to "123-X-123". Here's one that is more
strict, though I'm not sure what the best definition is in this case:
s/ (?: ^ | (?<= \s ) ) ( \d{5} (?: -\d{4} )? ) (?= \s | $ ) /X/x;
More permissive:
s/ (?: ^ | (?<= [^\d-] ) ) ( \d{5} (?: -\d{4} )? ) (?= [^\d-] | $ ) /X/x;
That last allows for things like "Zip:12345-6789" or "12345-6789, "
but still blocks "12345-6789-123".
--
Ren Maddox
ren@tivoli.com
------------------------------
Date: 26 Apr 2001 14:10:58 -0500
From: Ren Maddox <ren@tivoli.com>
Subject: Re: Regular expression for zip code
Message-Id: <m3itjrtr25.fsf@dhcp9-172.support.tivoli.com>
On Thu, 26 Apr 2001, notmyrealemail@fake.com wrote:
[Jeopardectomy. Please place your comments below the suitably-trimmed
portion of the message to which you are commenting.]
>> The following regular expression does not work!
>>
>> s< (\b\d{5}\b) | (\b\d{5}-\d{4}\b) > <X>x;
>>
>> From the number "12345-1234", it will return "X-1234".
>>
>> I am *guessing* that since the operation is an OR, the first part
>> matches and the second part never gets evaluated, thus producing
>> the results you are seeing.
> Yes, but the first part shouldn't match at all!
Why not? Oh -- you expect "\b" to not match between a digit and a
"-". But it does. It matches between a "\w" (word character) and a
"\W" (non-word character), where "\w" is [a-zA-Z0-9_] (ignoring
locale) and "\W" is everything else (including "-").
(Or between a word character and either end of the string.)
I do occasionally feel like a zero-width assertion that matches
between a "\s" and a "\S" would be useful. It seems like I often end
up employing "(?:^|(?<=\s))" and "(?!\s|$)". I would much rather have
a two-character assertion for that, but I have no idea what it would
be. All of the reasonable choices seem to be taken (eg. \b, \s, \w).
--
Ren Maddox
ren@tivoli.com
------------------------------
Date: Thu, 26 Apr 2001 21:15:28 -0000
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Regular expression for zip code
Message-Id: <teh3vghlim8u00@corp.supernews.com>
Craig Berry (cberry@cinenet.net) wrote:
: s/\b\d{5}(?:-\d{4})\b/X/;
Oops...add a '?' just before the final \b. Sorry.
--
| Craig Berry - http://www.cinenet.net/~cberry/
--*-- "When the going gets weird, the weird turn pro."
| - Hunter S. Thompson
------------------------------
Date: Thu, 26 Apr 2001 14:15:29 -0700
From: "Jürgen Exner" <juex@deja.com>
Subject: Re: Regular expression for zip code
Message-Id: <3ae88ff2$1@news.microsoft.com>
"BarryK" <notmyrealemail@fake.com> wrote in message
news:65YF6.28957$U4.6334726@news1.rdc1.tn.home.com...
> I want to create a regular expression that will replace any legitimate zip
> code in either five digit format or 5-4 digit format with something.
On a side note:
I hope you are aware that "legitimate zip code" and "five digit format or
5-4 digit format" are NOT(!) synonymous.
Although there are indeed quite a few countries which use 5-digit zip codes
there are far more which use a different format (or even no zip code).
jue
------------------------------
Date: 26 Apr 2001 14:14:31 -0400
From: Joe Schaefer <joe+usenet@sunstarsys.com>
Subject: Re: run by click in linux
Message-Id: <m3g0evmsu0.fsf@mumonkan.sunstarsys.com>
Ying Hu <yhu@mail.nih.gov> writes:
> hi,
> how can I run one perl script by click the icon in Linux. Thanks
^^^ ^^^^ ^^^^^^ ^^^^^ ^^^^ ^^^^^
Of those 6 keywords, how did you surmise that perl was the most
relevant one?
Drop "perl" from your question and it still makes perfect sense,
so you should choose a more appropriate newsgroup instead.
Thanks.
--
Joe Schaefer "It is easier to stay out than get out."
--Mark Twain
------------------------------
Date: Thu, 26 Apr 2001 11:30:51 -0700
From: Martin Djernaes <martin@djernaes.net>
Subject: Re: s///g count
Message-Id: <3AE8695B.1BBDF6E1@djernaes.net>
Hi,
Jay Tilton wrote:
> The return value of s/// is the number of substitutions it performed.
>
> my $foo = $str =~ s/a/A/g;
Thanks
Martin
------------------------------
Date: 26 Apr 2001 19:21:57 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: s///g count
Message-Id: <9c9sgl$fca$1@mamenchi.zrz.TU-Berlin.DE>
According to Martin Djernaes <martin@djernaes.net>:
> Hi,
>
> Maybe I'm just looking in the dark,but I can't find a way to see if
> s///g actually have replaced something.
>
> Let's say I have a string
>
> $str = 'ascdef';
>
> and I do a
>
> $str =~ s/a/A/g;
>
> How do I know if s/// actually did replace something? I guess I could
> compare the strings afterwards, but... does not seem like the best
> solution.
Your original question has been answered. I'd like to note that
comparing the strings afterwards gives a slightly different result:
It shows whether the string has been *changed* by a substitution.
Even if one or more substitutions have been made, the resulting string
could be the same as before.
Anno
------------------------------
Date: Thu, 26 Apr 2001 13:35:00 -0700
From: Martin Djernaes <martin@djernaes.net>
Subject: Re: s///g count
Message-Id: <3AE88674.29F663F@djernaes.net>
Hi Anno,
Anno Siegel wrote:
> According to Martin Djernaes <martin@djernaes.net>:
> > Maybe I'm just looking in the dark,but I can't find a way to see if
> > s///g actually have replaced something.
> Your original question has been answered. I'd like to note that
> comparing the strings afterwards gives a slightly different result:
> It shows whether the string has been *changed* by a substitution.
> Even if one or more substitutions have been made, the resulting string
> could be the same as before.
OK if a replace, replaces something else, but at least in my current
situation that can't be the case. Anyway it's true that's the only safe
way to know if something is changed, is by comapring the strings.
Martin
------------------------------
Date: Thu, 26 Apr 2001 21:06:36 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: s///g count
Message-Id: <8e3het8hkjhic867rm8lrh0mm0dmoqaktq@4ax.com>
Martin Djernaes wrote:
>Let's say I have a string
>
> $str = 'ascdef';
>
>and I do a
>
> $str =~ s/a/A/g;
>
>How do I know if s/// actually did replace something?
See in the docs what s/// used as a function returns. In perlop.
--
Bart.
------------------------------
Date: 26 Apr 2001 21:19:35 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: s///g count
Message-Id: <9ca3d7$kqh$1@mamenchi.zrz.TU-Berlin.DE>
According to Martin Djernaes <martin@djernaes.net>:
> Hi Anno,
>
> Anno Siegel wrote:
> > According to Martin Djernaes <martin@djernaes.net>:
> > > Maybe I'm just looking in the dark,but I can't find a way to see if
> > > s///g actually have replaced something.
>
> > Your original question has been answered. I'd like to note that
> > comparing the strings afterwards gives a slightly different result:
> > It shows whether the string has been *changed* by a substitution.
> > Even if one or more substitutions have been made, the resulting string
> > could be the same as before.
>
> OK if a replace, replaces something else...
Do you mean, something is replaced by itself? That is one way, but
more complex situations exist. It can't be too hard to construct
a s///g that changes "a" to "an" and "norange" to "orange", thereby
busily transforming "anorange" into itself.
Oh, okay,
s/(a|norange)/${ { a => 'an', norange => 'orange'}}{ $1}/g;
Anno
------------------------------
Date: Thu, 26 Apr 2001 19:49:56 GMT
From: pat@ssih.com (Pat Traynor)
Subject: Separate syslog file?
Message-Id: <3ae87a7f.22506243@news.giganews.com>
I'm successfully logging output to my syslog file like this:
use Sys::Syslog qw(:DEFAULT setlogsock);
setlogsock('unix');
syslog('info', "Test message to syslog filel\n");
I understand how to send different levels of priority messages to
different log files via syslog.conf, but is there a way to have a
program log output to a custom log level? e.g.:
syslog('mytest', "Test message to syslog filel\n");
------------------------------
Date: 26 Apr 2001 18:35:14 GMT
From: black@csulb.edu (Matthew Black)
Subject: Re: SGI IRIX fork() syscall: child process doesn't terminate after exit
Message-Id: <9c9pp2$4k0$1@hatathli.csulb.edu>
In article <9c7guh$f2q$1@hatathli.csulb.edu>, black@csulb.edu says...
Thank you everyone for your help with my problem.
I solved the problem by adding a child process reaper to my server.
Here's the code added to my test program previously posted:
Added this line at beginning of program:
use POSIX qw(:signal_h :errno_h :sys_wait_h);
Pasted to end of program:
sub REAPER {
my $pid;
WAITFOR: {
$pid = waitpid(-1, &WNOHANG);
if ($pid == -1) {
# no child waiting. Ignore it.
} elsif (WIFEXITED($?)) {
print "Process $pid exited.\n";
redo WAITFOR;
} else {
print "False alarm on $pid.\n";
}
}
$SIG{CHLD} = \&REAPER; # in case of unreliable signals
}
matthew black
csulb network services
------------------------------
Date: 26 Apr 2001 18:37:21 GMT
From: black@csulb.edu (Matthew Black)
Subject: Re: SGI IRIX fork() syscall: child process doesn't terminate after exit
Message-Id: <9c9pt1$4k0$2@hatathli.csulb.edu>
In article <slrn9eg36c.qli.abigail@tsathoggua.rlyeh.net>, abigail@foad.org
says...
>
>That's neither a problem with Perl, nor with IRIX.
>
>The problem lies in the programs author not understanding the Unix
>process model.
>
>Please consult the perlipc man page and find out why parents need to
>reap their children, lest they become zombies.
Yeah, that man page didn't exist when I wrote the code several
years ago. Nor was it discussed in my Llama book.
matthew
------------------------------
Date: Thu, 26 Apr 2001 17:29:38 -0400
From: "David J. Marcus" <djmarcus@ex-pressnet.com>
Subject: Single character reads on sockets
Message-Id: <teh4pn7g6kmv0b@corp.supernews.com>
Hi
I am trying to write a client and a server that communicate using the
following simple protocol:
- length of content-length field (1 character)
- length of content
- content
For example, when sending the string 'hello', the message actually sent is:
211hello there
where the '2' is the length of the '11', and 11 is the length of 'hello
there'.
This allows fixed length reads and writes.
On the both the reader and listener side I have used $| = 1 but to no avail.
On the reader side I do:
read ( $sock, $lenlen, 1 );
read ( $sock, $len, $lenlen );
read ( $sock, $msg, $len );
It seems that the first read hangs.
Am I doing things correctly?
Any suggestions? hints? advice? etc?
-TIA
David
------------------------------
Date: 26 Apr 2001 19:05:58 +0100
From: nobull@mail.com
Subject: Re: Sockets, Time-outs, and Alarms
Message-Id: <u9d79zilix.fsf@wcl-l.bham.ac.uk>
eins@durchnull.de (Rudolf Polzer) writes:
> nobull@mail.com <nobull@mail.com> wrote:
> > Anyhow I can't recall for sure but I think ignored signals don't
> > interrupt system calls.
>
> Sorry for this stupid question but is it possible in C to ignore
> signals without using a procedure that does nothing?
Yes, see the sigaction(2) and/or signal(2) man page.
> $SIG{USR1} = "IGNORE";
This tells the OS not to pass SIGUSR1 into userspace but to ignore
it.
> $SIG{USR1} = sub { };
This tells the OS to pass SIGUSR1 into userspace, and tells Perl to
then do nothing when this happens.
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Thu, 26 Apr 2001 13:46:19 -0700
From: Peter White <hpya78@postoffice.pacbell.net>
Subject: split and array problem
Message-Id: <3AE8891B.34D4CE80@postoffice.pacbell.net>
--------------CB6992CA845371F7E7B02CF7
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Hi all,
Can someone help me fix this script?
How to get the lines that with a number between 0 and 100?
File:
aa 45 23 22
bb 2 12 67
dd 99 98 100
ff 101 99 100
mm 56 87 1
nn 10000 999 1
------------------------
Ouput should be:
aa 45 23 22
bb 2 12 67
dd 99 98 100
mm 56 87 1
#!/user/bin/perl -w
open(FILE, "abc.txt") || die "Cannot open\n";
@abc=(<FILE>);
foreach $info(@abc)
{
($word, @nums)=split(/\s+/, $info);
foreach $digit(@nums)
{
if($digit>= 0 && $digit <=100)
{
print " $word @nums\n";
}
}
}
--------------CB6992CA845371F7E7B02CF7
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
Hi all,
<p>Can someone help me fix this script?
<br>How to get the lines that with a number between 0 and 100?
<p><b>File:</b>
<br>aa 45 23 22
<br>bb 2 12 67
<br>dd 99 98 100
<br>ff 101 99 100
<br>mm 56 87 1
<br>nn 10000 999 1
<br>------------------------
<br><b>Ouput should be:</b>
<br>aa 45 23 22
<br>bb 2 12 67
<br>dd 99 98 100
<br>mm 56 87 1
<br>
<p>#!/user/bin/perl -w
<p>open(FILE, "abc.txt") || die "Cannot open\n";
<p>@abc=(<FILE>);
<p>foreach $info(@abc)
<br>{
<br> ($word, @nums)=split(/\s+/,
$info);
<p> foreach $digit(@nums)
<br> {
<br>
if($digit>= 0 && $digit <=100)
<br>
{
<br>
print " $word @nums\n";
<br>
}
<br> }
<br>}
<br>
<br>
<br> </html>
--------------CB6992CA845371F7E7B02CF7--
------------------------------
Date: Thu, 26 Apr 2001 21:10:40 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: split and array problem
Message-Id: <4k3hetg5im501f54e7d8qvfqcctssrmhur@4ax.com>
Peter White wrote:
>Can someone help me fix this script?
>How to get the lines that with a number between 0 and 100?
You seem to want a variation on the theme of the grep program. Here
goes:
#! perl -n
print if /(-?)(\d+)/ and $2 <= 100 and not $1;
--
Bart.
------------------------------
Date: Thu, 26 Apr 2001 21:33:57 GMT
From: Dan Sugalski <dan@tuatha.sidhe.org>
Subject: Re: US$50 prize for hash failure from 'delete' inside an 'each' loop
Message-Id: <9v0G6.28592$Ce4.2103303@news1.rdc1.ct.home.com>
In comp.lang.perl.misc Malcolm Dew-Jones <yf110@victoria.tc.ca> wrote:
> : In comp.lang.perl.misc Mark-Jason Dominus <mjd@plover.com> wrote:
> : > The 'perlfunc' man page says:
> : > each ...
> : >
> : > If you ... delete elements of a hash while you're
> : > iterating over it, you may get entries skipped or
> : > duplicated...
> : > I will give a $50 prize to the first person who can come up with an
> : > example that demonstrates this.
> Perhaps the pod is giving you a clear warning that the code is not
> consciously written to accomodate deleting elements while iterating over
> them using each.
It is, though. If you delete the current element you're iterating
on, it isn't really removed. Rather it's marked as deleted and
removed the next time through the iteration. Normally when
you delete a hash entry it gets immediately removed.
Dan
------------------------------
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.
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 775
**************************************