[6518] in Perl-Users-Digest
Perl-Users Digest, Issue: 143 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Mar 19 08:07:18 1997
Date: Wed, 19 Mar 97 05:00:35 -0800
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, 19 Mar 1997 Volume: 8 Number: 143
Today's topics:
Re: 2 fields 2 files (Lars Gregersen)
Re: ANNOUNCE: eZone Online Interactive Courses (with ce (John Goerzen)
Can we create an Perl executable akench@cvimail.cv.com
Re: Directory access Denying (Clay Irving)
Re: Executable? <dehon_olivier@jpmorgan.com>
Re: Executing a PERL program by dropping a file in a di <piet@cs.ruu.nl>
File::Find::find doesnt follow softlinks on mounted fs (Rainer Stengele)
Re: How To Pattern Match To The First Occurance Of A Ch <dbenhur@egames.com>
Re: How To Pattern Match To The First Occurance Of A Ch <ishark@lsh01.univ-lille1.fr>
Re: How to read a Fixed Format File? (Honza Pazdziora)
Re: I'm scared and don't know what to do. Do you know?? <mas@dial.pipex.com>
Re: Lost backslash <dbenhur@egames.com>
Need to extract the text from Microsoft Word 6 files <John.Clutterbuck@sbs.siemens.co.uk>
Newbie Question on accessing elements of Strings (Mark Glover)
Re: Newbie Question on accessing elements of Strings (Lars Gregersen)
ODBC package problem (Donovan Janus)
Re: Parsing html tag attributes & values in Perl (Dan Sumption)
PERL5-WIN32,NT4.0,IIS2.0 problem executing external sys upi@uslink.net
Problems with flock() (Jim Rudolf)
Re: Signaling a child process (Charles DeRykus)
Re: SORTING ... one more Q (Eric D. Friedman)
Re: text to HTML <dbenhur@egames.com>
Re: What's a good Perl book? (John Goerzen)
Re: Windows 3.11 and Perl <harald.joerg@mch.sni.de>
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 19 Mar 1997 12:30:42 GMT
From: lg@kt.dtu.dk (Lars Gregersen)
Subject: Re: 2 fields 2 files
Message-Id: <332fdc0c.20912715@130.228.3.8>
On Wed, 19 Mar 1997 08:14:39 +0000, John Clark <john@mcl.net> wrote:
>I have 2 fields in 2 files. A and B in file 1, A and C in file2.
>Fields A in both files are not necessary in the same order and some
>entries may be missing. How do I use keys to sort and print ABC.
If I understand you correctly: Read your files into a %hash.
Do a foreach loop using sort keys %hash and print the keys.
Somebody must be able to do this in a one-liner, I guess.
Lars Gregersen
Technical University of Denmark
Department of Chemical Engineering
E-mail : lg@kt.dtu.dk
Homepage: http://www.gbar.dtu.dk/~matlg/
------------------------------
Date: 17 Mar 1997 05:37:35 GMT
From: jgoerzen@complete.org (John Goerzen)
Subject: Re: ANNOUNCE: eZone Online Interactive Courses (with certification!)
Message-Id: <slrn5ipm4v.9nu.jgoerzen@complete.org>
On Wed, 12 Mar 1997 01:32:12 GMT, Steven Katz <skatz@waite.mcp.com> wrote:
>>Stop by and be our guest for a tour of the future of online learning!
>>
>
>You can now receive real CEU Continuing Education Units from Marquette
>University for any course currently available on the eZone. Marquette
But taking a class (or getting credit for taking a class) is certainly
different from being certified. And I still haven't seen anything to
indicate that there is any independant organization that sets requirements
for certification, etc.
>Univesity, based in the US, is a well honored 100 year old university with a
>rich history of Jesuit tradition. Over the years Marquette has adopted a role
>in teaching state of the art courses in a wide range of subjects, including a
>very strong computer science curiculum. It was only natural that Waite Group
>and Marquette would one day meet.
>
>For more information, follow the Marquette links from the eZone.
>http://www.waite.com/ezone
>
>--
>Steve Katz, Webmaster
>Waite Group Press
>
--
John Goerzen | Running Debian GNU/Linux (www.debian.org)
Custom Programming |
jgoerzen@complete.org |
------------------------------
Date: Wed, 19 Mar 1997 14:53:11 +0500
From: akench@cvimail.cv.com
Subject: Can we create an Perl executable
Message-Id: <199703190953.OAA09490@bandar.CV.COM>
Hi Perl Gurus,
Can we compile and build a PERL script
to get an excutable? I am using PERL scripts
as call backs from the GUI. Since some of the
scripts are big the responce time is not good enough.
Hoping that running an executable will
help, cause it'll save the compilation time.
Also pl. tell me about any limitation
for the executables so created.
thanks and regards,
-Atul
Computervision, Pune, India
(akench@cvimail.cv.com)
------------------------------
Date: 19 Mar 1997 07:15:15 -0500
From: clay@panix.com (Clay Irving)
Subject: Re: Directory access Denying
Message-Id: <5golcj$n76@panix.com>
In <332fed36.53907879@202.37.101.7> vss@xtra.co.nz (Jeremy Coulter) writes:
>A friend asked me to write a perl script that deals with Passwords to
>stop people getting access to certain pages on his server.
>As I explained to him, once they are in, they only have to bookmark
>the page, and they can by-pass the password log in.
>So I suggested that allowing only certain people access to a directory
>where the pages are stored.
>I have a perl book that told me that I can use "AuthDBMUserFile" to
>point to a file that houses valid users names, and therefore, only
>thoses people can get access to that directory.
>The only thing is, I don't know how to use this procedure, and my book
>leaves me a bit in the dark.
>Does anybody have an example of what I want to do ?
Pssst. Hey, buddy. This has nothing to do with Perl, but would you like
to buy a .htaccess file? :)
Try:
http://hoohoo.ncsa.uiuc.edu/docs/tutorials/user.html
I'd also recommend:
comp.infosystems.www.authoring.html
since your question is better answered there.
--
Clay Irving See the happy moron,
clay@panix.com He doesn't give a damn,
http://www.panix.com/~clay I wish I were a moron,
My God! Perhaps I am!
------------------------------
Date: 19 Mar 1997 10:22:15 +0100
From: Olivier Dehon <dehon_olivier@jpmorgan.com>
Subject: Re: Executable?
Message-Id: <njzrahcz16g.fsf@jpmorgan.com>
"Mike Smith" <masmith@telusplanet.net> writes:
>
> I put a perl script on my isp's cgi server last week. I telnet to the
> server, type perl mcr.cgi in the directory where the script is and
> everything works fine. The tags print to screen and such. I used chmod 777
> mcr.cgi to make it executable. Doesn't that mean I can tpye mcr.cgi
> (without running perl; ie. perl mcr.cgi)? Anyway, when I type mcr.cgi Unix
> gives me a "bad command" message.
>
The first line of your script has to be of the form:
#!/usr/local/bin/perl -w
This tells the system that it must launch this command and
that the file is not just a binary executable (which has some other
kind of header, presumably).
Hope this helps.
Olivier Dehon
------------------------------
Date: 19 Mar 1997 13:06:23 +0100
From: Piet van Oostrum <piet@cs.ruu.nl>
Subject: Re: Executing a PERL program by dropping a file in a directory?
Message-Id: <wzybbkaxxc.fsf@kemmel.cs.ruu.nl>
>>>>> Anirvan Chatterjee <anirvan@crl.com> (AC) writes:
AC> -----BEGIN PGP SIGNED MESSAGE-----
AC> Michael Stearns <mstearns@darkwing.uoregon.edu> wrote:
AC> : Is it possible to execute a Perl program that processes a file just by
AC> : putting (ftpping) the file in a specific directory?
AC> Offhand, I'd guess that the two ways to do this would be to either [1]
AC> have the relevant perl processing script be called regularly by cron
AC> (say every minute or so), or [2] by turning the perl program into a
AC> daemon process that lingers in the background, checking the directory
AC> at some set small interval and processing files as they come in.
And of course you must be very careful to process the file only after the
ftp'ing is complete. Which may be difficult to find out, especially on a
slow link. If you can force the upload to conform to specific rules, a good
way would be to upload the file to be processed first, followed by an
"announcement file" which may even be empty. If they will always be
uploaded in this order, the presence of the "announcement file" indicates a
completed upload of the original file.
--
Piet van Oostrum <piet@cs.ruu.nl>
URL: http://www.cs.ruu.nl/~piet [PGP]
------------------------------
Date: 19 Mar 1997 10:54:25 GMT
From: rainer@alfred.diplan.osn.de (Rainer Stengele)
Subject: File::Find::find doesnt follow softlinks on mounted fs
Message-Id: <5gogl1$2h2@firewall.diplan.osn.de>
Keywords: find softlinks nfs
Hallo dear reader!
I'm running an SCO ODT3 BOX and perl V5.002.
The Find routine in lib/perl5/File/Find.pm shows a problem for me:
If I use it on a local filesystem, it will be following softlinks
without problems.
If I use it on a remote filesystem mounted via automount-nfs,
it doesn't follow the softlinks. I checked rights and the
softlinked path and could change to the pointed directory
in my shell (bash).
Can anybody give me a hint or solution. The documentation
of the module is not explicit enough for my understanding.
(sorry for the bad english)
Rainer.
--
__|___
| Rainer Stengele email: rainer@diplan.osn.de
| voice: ++49-9131-777815
| fax: ++49-9131-777888
| http://www.diplan.osn.de
| diplan GmbH, Am Weichselgarten 11, 91058 Erlangen, Germany
------------------------------
Date: Tue, 18 Mar 1997 21:59:57 -0800
From: Devin Ben-Hur <dbenhur@egames.com>
To: Rhadji P <dharma@msys.net>
Subject: Re: How To Pattern Match To The First Occurance Of A Character
Message-Id: <332F80DD.C20@egames.com>
[mail&post]
Rhadji P wrote:
> <TEXTAREA NAME="area 1" ROWS="10" COLS="10"></TEXTAREA>
> I want $1 to equal NAME="area 1" ROWS="10" COLS="10"
> but the pattern /<TEXTAREA(.*)>/
> gobbles up the string to the second ">" causing
> $1 to equal NAME="area 1" ROWS="10" COLS="10"></TEXTAREA
The regex "repeaters" (*,+,?,{min,max}) are greedy. That
is they will gobble as many characters as they can while
still allowing a successful match for the whole regex.
This is why the (.*) grabs everything up to the last '>'
in your example.
There are two obvious ways to fix your regex to do what you
want.
1) Use a ? after .* to make it non-greedy:
/<TEXTAREA(.*?)>/
2) Instead of . (which matches any character except \n),
use a character class which matches any character except
the '>' which terminates the tag:
/<TEXTAREA([^>]*)>/
I highly recommend Jeffrey Friedl's "Mastering Regular
Expressions" to help you understand this stuff.
HTH
--
Devin Ben-Hur <dbenhur@egames.com>
eGames.com, Inc. http://www.egames.com/
eMarketing, Inc. http://www.emarket.com/
"Sometimes you just have to step in it and see if it stinks" O-
-- Sonia Orin Lyris
------------------------------
Date: 19 Mar 1997 11:33:15 +0100
From: Alberto Barsella <ishark@lsh01.univ-lille1.fr>
Subject: Re: How To Pattern Match To The First Occurance Of A Character
Message-Id: <p3lk9n4893o.fsf@lsh01.univ-lille1.fr>
dharma@msys.net (Rhadji P) writes:
> I must be missing something. It can't be that difficult.
Regexp are not difficoult. They are messy :)
> What I'm trying to do is pattern match to the first occurance of a
> character.
[example deleted]
> How do I pattern match to the first occurance of > ?
I normally use the regexp:
[^>]*
but I think you can also use the non-greedy modifier (something like
'.*?>', can't remember if the non greedy modifier is '?')
Alberto
------------------------------
Date: Wed, 19 Mar 1997 10:46:41 GMT
From: adelton@fi.muni.cz (Honza Pazdziora)
Subject: Re: How to read a Fixed Format File?
Message-Id: <adelton.858768401@aisa.fi.muni.cz>
baruch@macom.co.il (Baruch Promislow) writes:
> Hi!
> Is there a way to define a FORMAT for inputing from fixed formatted files,
> similar to the output formats?
>
> I have done all kind of experiments using formats as if for outputting,
> reading a file, but this does not work.
You will probably want to just read the file and do unpack on it to
get the entries into your variables.
Hope this helps.
--
------------------------------------------------------------------------
Honza Pazdziora | adelton@fi.muni.cz | http://www.fi.muni.cz/~adelton/
I can take or leave it if I please
------------------------------------------------------------------------
------------------------------
Date: Wed, 19 Mar 1997 10:06:23 +0000
From: Martin Ansdell-Smith <mas@dial.pipex.com>
Subject: Re: I'm scared and don't know what to do. Do you know??
Message-Id: <kRR+1FAfq7LzEwZ6@ansdell.demon.co.uk>
In article <3328E1B9.40EB@ibm.net>, Hank LeMieux <hanklem@ibm.net>
writes
>Tom,
>
>If you must use perl (which is what I use), then you need to do a couple
>of things. Learn perl first. CGI, which is much easier, comes later.
>Go get the interpreter and supporting software at
><http://www.perl.com/perl/index.html>. You'll also find documentation
>and recommended books and online resources there. DEFINITELY
>ABSO_POSI_LUTELY buy a good perl book. It will save you DAYS. The camel
>and llama books are highly recommended. I wouldn't be surprised if they
>were at a nearby library.
Whilst you're looking at the library for the O'Reilly perl books, have a
look at their recent book on CGI : "CGI Programming on the World Wide
Web" by Shishir Gundavaram. It gives examples of several CGI apps with
examples in perl that you might find useful starting points - and of
course you could see how others have done these sort of things on the
web already.
>
>Take advantage of the FAQ's and the existing perl script archives. You
>can learn a lot and perhaps borrow some code snippets from the
>archives. For that matter, there are already public distribution copies
>of scripts that do what you're wanting to do. Just search for perl
>script archives on Yahoo.
Martin Ansdell-Smith
Network Analyst website: http://www.demon.co.uk/ansdell/
------------------------------
Date: Tue, 18 Mar 1997 22:09:20 -0800
From: Devin Ben-Hur <dbenhur@egames.com>
To: buehner@pfaffenhofen.netsurf.de
Subject: Re: Lost backslash
Message-Id: <332F8310.126D@egames.com>
Thomas Buehner wrote:
> $test = '\.\\test';
> print $test;
>
> what gets printed is: \.\test
The only characters which get backslash-interpreted within
single-quoted literals are \' and \\.
See Camel p.39 or man perlop.
HTH
--
Devin Ben-Hur <dbenhur@egames.com>
eGames.com, Inc. http://www.egames.com/
eMarketing, Inc. http://www.emarket.com/
"Sometimes you just have to step in it and see if it stinks" O-
-- Sonia Orin Lyris
------------------------------
Date: Wed, 19 Mar 1997 09:30:28 +0000
From: John Clutterbuck <John.Clutterbuck@sbs.siemens.co.uk>
Subject: Need to extract the text from Microsoft Word 6 files
Message-Id: <332FB234.41C6@sbs.siemens.co.uk>
I hope someone can help me here!
I need to be able to reliably extract the text from files stored by
Microsoft Word6 in either Word6 format (xxx.DOC) or Micrsofts RTF format
(xxx.RTF) using either a perl function or a system call to a Unix
utility (SGI Irix).
This will be run from a background script run from a cron job overnight,
and needs to be controllable from command line options if a system call.
The Word files will usually only contain simple paragraphs of text
without complex formatting or graphic objects etc.
In the rare case where a section cannot be decoded some form of
indicator would be desirable such as:
** SECTION CANNOT BE DECODED **
Does anyone know if anything such as this exists?. I know Billy the
Billionaire expects everyone to use a PC but it is not appropriate in
this situation.
Thanking you in anticipation.
--
# John Clutterbuck Tel: +44 1703 765021
# Siemens Business Services email: jclutterbuck@sbs.siemens.co.uk
# Phi House, Enterprise Road
# Chilworth, Hampshire, SO16 7NS
------------------------------
Date: Wed, 19 Mar 1997 11:14:38 GMT
From: mglover@rnib.org.uk (Mark Glover)
Subject: Newbie Question on accessing elements of Strings
Message-Id: <5gohua$fmi@bore.pipex.net>
I am sure there is a very simple and obvious answer to this question,
but I can't find the answer in any of the books I have!
I am reading lines of text into a string from a file using the READ
function call and now I want to cycle through the string character by
character but because PERL strings are not arrays I cannot see how to
do this; in 'C' I would simply do:-
for (n=0; n<strlen(str); ++n) {
do something useful with str[n];
}
Any help would be very much appreciated.
Mark
------------------------------
Date: Wed, 19 Mar 1997 12:27:41 GMT
From: lg@kt.dtu.dk (Lars Gregersen)
Subject: Re: Newbie Question on accessing elements of Strings
Message-Id: <332fda9c.20544561@130.228.3.8>
On Wed, 19 Mar 1997 11:14:38 GMT, mglover@rnib.org.uk (Mark Glover)
wrote:
>I am sure there is a very simple and obvious answer to this question,
>but I can't find the answer in any of the books I have!
>
>I am reading lines of text into a string from a file using the READ
>function call and now I want to cycle through the string character by
>character but because PERL strings are not arrays I cannot see how to
>do this; in 'C' I would simply do:-
> do something useful with str[n];
If you really like to read a string character by character you can
attack it by using
substr
or you can convert it into an array by
split //
Sometimes you can even use
unpack
It is of course pretty hard to guess why you want to do this and my
guess is that you can access you data much smarter in Perl than doing
it character by character (but I could be wrong).
Lars Gregersen
Technical University of Denmark
Department of Chemical Engineering
E-mail : lg@kt.dtu.dk
Homepage: http://www.gbar.dtu.dk/~matlg/
------------------------------
Date: Wed, 19 Mar 1997 10:15:26 GMT
From: donovan@zaak.nl (Donovan Janus)
Subject: ODBC package problem
Message-Id: <332fba2a.54220669@news.xs4all.nl>
Hi
I am trying to connect to an SQL server with the Win32::ODBC module.
I have Perl 5 build 110, version 5.001 on a Windows NT 4 server.
My systemadministrator installed all the files (well, the .pm and the
.pll files) into the right directories and when I want to connect to
my SQL with the following code:
use Win32::ODBC;
$Data = new Win32::ODBC("DSN=DeZaak;UID=MyName;PWD=MyPassWord");
($qualifier, $owner, $name, $type) = $Data->Catalog("", "", "%",
"'TABLE'");
$Data->Close();
I get the error:
Can't call method "Catalog" without a package or object reference at
line 3.
When I ran the test.pl which comes along with the Win32::ODBC module I
do get the DSN name and all other bits of pieces which shows evidence
that there is a connection the ODBC manager.
I need some help on this urgently and I have been browsing the web
(http://www.perl.org, www.perl.com, www.hip.activeware.com etc.) and
although they all showed me what to do, none of them gave a solution
to this error.
Many thanks in advance,
Donovan Janus
janus@zaak.nl
BTW, I already ordered the book "WWW database Programming for Windows
NT" and I also have the "WWW database developers guide" and the last
one doesn't has anything on the subject and the first one hasn't
arrived yet nor will for the next 3 weeks.
------------------------------
Date: Wed, 19 Mar 1997 08:54:52 GMT
From: dan@gulch.demon.co.uk (Dan Sumption)
Subject: Re: Parsing html tag attributes & values in Perl
Message-Id: <3330a84b.1294891@news.demon.co.uk>
Cynthia Rossbach wrote:
>Seems to me you need a pushdown stack or perhaps two.
>you would push < on the stack, if you hit a > you would pop a <
>from the stack. If there's nothing to pop then error.
>if the stacks not empty at the end of a file you know you have some missing <
>what if you actually have more >'s then <'s?
>send an error message? (e.g. the nothing to pop case above)
This would definitely help in the case where I had sent two lots of tags to
the subroutine by accident. However, in my example case where I pass the
tag:
<img src="arrow.gif" alt="Look Here >">
it would throw up an error, which I don't want!
However, I think it's got me writing along the correct lines. Maybe I'll
crack the nut today!
-------------------------------------------------------------------
Dan Sumption : dan@gulch.demon.co.uk
Hard Media, London SE1 dan@hardnet.co.uk
http://www.hardnet.co.uk/dan/
------------------------------
Date: Tue, 18 Mar 1997 18:01:36 -0600
From: upi@uslink.net
To: upi@uslink.net
Subject: PERL5-WIN32,NT4.0,IIS2.0 problem executing external system commands
Message-Id: <858727791.25585@dejanews.com>
Config:
-NT 4.0
-IIS 2.0
-Perl5-Win32 (303)
Problem:
The following code works fine when executing PERL from a command
prompt, but does not return my directory when connecting to my
IIS server with a browser.
I attempt to execute the code through my browser with this commamd which
I enter in the URL box directly:
http://my_IP/cgi-bin/test.pl
The script (test.pl):
print "Content-type: text/plain \n\n";
print "Current Directory.\n";
$test = qx{ dir };
print "$test\n";
print "Finished.";
In my browser I am returned:
Current Directory:
Finished
>From a command prompt on my IIS server I execute:
perl test.pl
my output:
Current Directory:
<direcory information displayed normally>
Finished.
I HAVE BEEN STRUGGLING WITH THIS FOR TOO LONG AND I AM STARTING TO
RETHINK USING PERL with IIS and NT.
It seems that the 'qx' command which should envoke the command processor,
in this case CMD.EXE, will envoke fine and return the output to my
variable
if this script is started from a command prompt, but for some reason, IIS
is not letting this script execute the command processor, that's my guess
anyway.
What I am ultimately trying to do is adapt Matt's (from Matt's Script
Archive)
Simple Search script, which was written for UNIX.
In his script he shells out to use the UNIX 'ls' command to retrieve a
recursed directory listing, I simple want to replace that command
with the equivalent 'dir /s/l/b' for NT. I have already adapted the rest
of the script to work fine under NT, this is the one hump I can't get
over.
Once I finish the script, I would be happy to mail it to anyone, as I'm
sure it could come in useful, or as a good alternative to doing anything
in 'C' or VB with ISAPI or whatever else, which seems to me to be more
difficult than working with PERL.
Any help would save me hours. Thanks in advance!
Please respond to one or all of the following addresses:
upi@uslink.net
gus@uslink.net
ericl@brainerd.net
Eric Lederman
-------------------==== Posted via Deja News ====-----------------------
http://www.dejanews.com/ Search, Read, Post to Usenet
------------------------------
Date: Wed, 19 Mar 1997 11:47:22 +0100
From: rudolf@metadesign.de (Jim Rudolf)
Subject: Problems with flock()
Message-Id: <rudolf-1903971147220001@jim.metadesign.de>
Greetings:
After checking the online & offline documentation, and failing to find
examples that use flock(), I'm turning to the Net. Given:
$lock_shared = 1;
$lock_exclusive = 2;
$lock_unlock = 8;
$fn = "/tmp/foo";
This attempt to open for reading and lock shared dies on the flock():
open(FILE, "<$fn") or die "cannot read $fn\n";
flock(FILE, $lock_shared) or die "cannot share $fn\n";
But this works:
open(FILE, "+<$fn") or die "cannot read $fn\n";
flock(FILE, $lock_shared) or die "cannot share $fn\n";
However once I have locked the file shared, trying to lock it again
shared from another process fails. The second process cannot lock
the file shared after the first process does an flock(FILE, $lock_unlock),
but instead waits until the close(FILE) by the first process. Can anyone
explain this behavior?
My environment: perl-5.003, Sun ultra, Solaris 2.5
Thanks in advance,
Jim
------------------------------
Date: Tue, 18 Mar 1997 19:56:05 GMT
From: ced@bcstec.ca.boeing.com (Charles DeRykus)
Subject: Re: Signaling a child process
Message-Id: <E798pH.MHq@bcstec.ca.boeing.com>
In article <5gjt5d$1req@uvaix3e1.comp.UVic.CA>,
Kim Lewall <klewall@uvaix3e1.comp.UVic.CA> wrote:
> I have a process which forks off a child. In the
> following simple example, the parent and child both
> start and then effectively wait.
>
> If I kill -s HUP the parent, the quit routine is
> invoked, and the response from kill('TERM', $pid);
> is 1, but the child never dies??? If I kill -s HUP the
> child, it never seems to get it.
>
> So why does it appear that the child never gets signals?
> This is perl, version 5.003 with EMBED
> built under aix 4.1.4
>
> -------------------------------
> #!/usr/local/bin/perl -w
>
> sub quit {
> local($Sig) = @_;
> return if $pid == 0;
>
> if ($Sig) { print STDERR "Caught a SIG$Sig -- killing $pid\n" }
> kill('TERM', $pid);
> waitpid($pid, 0);
> exit(0);
> }
>
> $SIG{'HUP'} = $SIG{'INT'} = $SIG{'QUIT'} = $SIG{'TERM'} = \&quit;
>
> if ($pid = fork) {
> print "parent waiting 1 $pid\n";
> waitpid($pid, 0); #parent
> print "parent waiting 2 $pid\n";
> } elsif (defined $pid) { #child
> print "child running 1 $pid\n";
> $SIG{'HUP'} = $SIG{'INT'} = $SIG{'QUIT'} = $SIG{'TERM'} = \&quit;
> while (1) {
> sleep(1);
> print "child sleeping\n";
> }
> print "child running 2 $scriptpid\n";
> }
> exit(0);
You have all kinds of signal snarl :)
A few things that're problmenatic:
1. Sending SIGTERM inside a SIGTERM signal handler will
produce recursion ("deep recursion on subroutine...")
2. The parent blocks very early on the waitpid call and
will just restart if there's a signal interrupt. I'm
suprised you were able to catch the parent early enough.
The child however can deal with the signal. This is good
news/bad news: you won't get deep recursion but that's all
that'll happen: your "quit" routine immediately returns in
the case of the child process.
3. Don't print, etc. in a signal handler. There's a list of
things somewhere that are safe to do in a signal hander
somewhere in the blue Camel I believe.
A block eval is usually the way to deal with the intricacies
of signals. See below for a possible solution. This works if
either the child or the parent is signalled.
P.S.
I was actually suprised that this worked for the parent though.
I would've thought that the parent would've just restarted.
The signal isn't ignored, however, and the program conveniently
dies. ERESTART is set however as I thought though since
die "$_[0]:$!" yields "TERM:Restart the system call...".
Can anyone explain this...?
$SIG{'HUP'} = $SIG{'INT'} = $SIG{'QUIT'} = $SIG{'TERM'} = \&quit;
sub quit { die $_[0] };
if ($pid = fork) {
waitpid($pid, 0); #parent
} elsif (defined $pid) { #child
while (1) {
eval { sleep(1) };
if ($@ =~ /^(TERM|INT|QUIT)/) {
print STDERR "quit - caught a $1\n";
exit;
} elsif ($@) {
print STDERR "weird eval: $@";
}
}
};
Sorry for the length of the post.
HTH,
--
Charles DeRykus
ced@carios2.ca.boeing.com
------------------------------
Date: 19 Mar 1997 10:16:42 GMT
From: friedman@medusa.acs.uci.edu (Eric D. Friedman)
Subject: Re: SORTING ... one more Q
Message-Id: <5goeea$gmp@news.service.uci.edu>
[posted, mailed]
In article <knlmg5.uc2.ln@localhost>, Tad McClellan <tadmc@flash.net> wrote:
[a helpful example showing how to write custom sort routines]
>This is _very_ inefficient. If your lists are large, you would want
>to use a different method (such as the Schwartzian Transform).
Is the Schwartzian Transform documented in some obvious place that
I've over looked? I've seen a number of allusions to it in recent
days, but have yet to catch a glimpse of the thing itself.
Suggestions for locating it (and any associated gloss) would be
much appreciated.
Eric
--
Eric D. Friedman
friedman@uci.edu
------------------------------
Date: Tue, 18 Mar 1997 22:24:10 -0800
From: Devin Ben-Hur <dbenhur@egames.com>
To: lewis@nexusint.com
Subject: Re: text to HTML
Message-Id: <332F868A.1F6C@egames.com>
[mail&post]
Lewis Taylor wrote:
> I am currently writing a primative text to HTML routine. I want to
> replace all instances of double carriage return (\n\n) with a paragraph
> tag. But this :
>
> $big_string =~ s/\n\n/<P>/g;
>
> does'nt seem to do anything. I have also tried the two \n's in a
> variable to no avail. Other printable chars in place of \n\n work. Can
> someone please help?
Well the above works fine for me. I suspect the problem
is that whatever created your text files uses a different
convention for marking the end of a line then the default
unix one of a single ASCII linefeed (which is what \n
represents). If you're on a Mac (or the text was created
there) the lines are marked by single CRs (\r), if DOS/Win
then the lines are terminated with CR,LF pairs (\r\n).
You might want to try something like:
$bigstring =~ s/\r\n|\r/\n/g; # fix non-unix EOLs
$bigstring =~ s/\n\n/<P>/g; # make blank lines into paragraphs
Some of your blanks lines might have some spaces or tabs
in them too, so that second line might be better as:
$bigstring =~ s/\n\s*\n/<P>/g;
HTH
--
Devin Ben-Hur <dbenhur@egames.com>
eGames.com, Inc. http://www.egames.com/
eMarketing, Inc. http://www.emarket.com/
"Sometimes you just have to step in it and see if it stinks" O-
-- Sonia Orin Lyris
------------------------------
Date: 17 Mar 1997 05:41:05 GMT
From: jgoerzen@complete.org (John Goerzen)
Subject: Re: What's a good Perl book?
Message-Id: <slrn5ipmbh.9nu.jgoerzen@complete.org>
On Tue, 11 Mar 1997 19:37:15 -0600, Tad McClellan <tadmc@flash.net> wrote:
>David Tong (dtong@lynx.dac.neu.edu) wrote:
>Reference:
>
>"Programming Perl" by Larry Wall, Tom Christiansen and Randal Schwartz
Let us not forget that it is important to get the **second edition** of this
book!
>both available from:
>
>http://www.ora.com
Or cheaper, from http://www.amazon.com, or (for the cheapest price I found),
from http://www.cheapbytes.com.
--
John Goerzen | Running Debian GNU/Linux (www.debian.org)
Custom Programming |
jgoerzen@complete.org |
------------------------------
Date: Wed, 19 Mar 1997 08:55:16 -0100
From: Harald Joerg <harald.joerg@mch.sni.de>
To: Zac <cgsystem@dircon.co.uk>
Subject: Re: Windows 3.11 and Perl
Message-Id: <332FB804.48D7@mch.sni.de>
Zac wrote:
> Is it possible to learn Perl on an old 486 running 3.11.
I hope so, since I'm currently trying to do that ;-)
I use Ilya Zacharevich's OS/2 port (Perl 5.003) and brought it to my
PC following a recipe which Dean Pentcheff posted here several times.
It allows me to test quite complex CGI scripts (including DB_File,
CGI, parts of libwww, etc) locally on my PC.
> I have a virtual Web Server with a full CGI capability, and very
> little idea on how to use it.
That's another thing. I don't have a Web server on my PC, nor
want to have one.
--
Cheers,
--haj-- (Harald Joerg, OEC SAM MC4, Mch P, Tel. 49726)
------------------------------
Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 8 Mar 97)
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.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 143
*************************************