[7193] in Perl-Users-Digest
Perl-Users Digest, Issue: 818 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Aug 6 21:07:25 1997
Date: Wed, 6 Aug 97 18:01:01 -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, 6 Aug 1997 Volume: 8 Number: 818
Today's topics:
Re: ? on Server Redirection with Perl (Eric Bohlman)
Re: [Q] Converter between ELM filter-rules file to proc (Martin Ramsch)
Re: [Q]: Use a Variable to Provide $vars to Split? <hollyhp@nospam.one.net>
CGI.pm Button and Input text problems dcolli@casc.com
Re: chop vs chomp (Jason Costomiris)
Re: Conversion of Word Processing files <petri.backstrom@icl.fi>
Re: Create E-mail with perl-script (Kim Holviala)
equivalent to map function <shenriques@us.socgen.com-NOSPAM>
Re: executing shell commands from perl. bug?! <clark@s3i.com>
Re: Have array, will (won't?) sort <bruceNoSpAm@pLeAsEgtcs.com>
Re: Help! - Reformatting Date (Mike Stok)
installation problems <#j.kiser@ix.netcom.com>
Re: Microsoft violating Perl license? (was Re: arrogant kerryg@delta.net
Need help with split (Torfinn Keringen)
Perl daemon program dies while sleeping <marcus@student.adb.gu.se>
Re: Perl Truncation <seay@absyss.fr>
Re: Perl Truncation (Craig Berry)
Possible Perl FAQ mistake about record separators? ajt@terlecki.demon.co.uk
Pre-forking server example needed (Robert Sturrock)
Problems Appending To A File <bgibbons@nsp-inc.com>
Re: Request help extracting acronyms (Marjorie Roswell)
Re: sleep not mixing well with other signal handlers (Charles DeRykus)
Re: What means --> Can't call method "xxxxxxx" on unble (Jot Powers)
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 7 Aug 1997 00:08:53 GMT
From: ebohlman@netcom.com (Eric Bohlman)
Subject: Re: ? on Server Redirection with Perl
Message-Id: <ebohlmanEEIoEt.A6A@netcom.com>
John Barnett (johnpb@ix.netcom.com) wrote:
: I have a question I hope some could answer. I would like to know if it
: is possible to redirect some to a WWW server based on IP or DNS name. I
: have two Web servers one on the East coast and the other on the West.
: Each coast is using a different IP subnet.
[snip material, noting that this is an intranet application, so all the
IPs are known locally]
: I'm not looking for a how to, just can to be done with Perl? or is
: there a better way with out modifying DNS servers tables?
Yep, it can be done in Perl. The CGI module (available at CPAN sites
near you) contains everything you need for this. Get it and read the docs.
------------------------------
Date: 6 Aug 97 23:46:48 GMT
From: ramsch@forwiss.uni-passau.de (Martin Ramsch)
Subject: Re: [Q] Converter between ELM filter-rules file to procmailrc file?
Message-Id: <slrn5ui371.558.ramsch@melian.forwiss.uni-passau.de>
On 6 Aug 1997 16:09:20 GMT, Sven Guckes <guckes@math.fu-berlin.de> wrote:
>Famous last words, eh? Well, your effort is much appreciated! :-)
>I just tried it on my filter-rules and the output looks ok. Good job!
Thanks, but there's still room for improvement :-)
It's work in progress ...
>what if I added a link from the filter or script page [*] to one of
>your pages?
You're welcome! Note that I just updated to V1.1 with some bugfixes
and additions.
Regards,
Martin
--
Martin Ramsch <m.ramsch@ieee.org> <URL: http://home.pages.de/~ramsch/ >
------------------------------
Date: Wed, 06 Aug 1997 18:28:11 -0400
From: Holly Henry-Pilkington <hollyhp@nospam.one.net>
Subject: Re: [Q]: Use a Variable to Provide $vars to Split?
Message-Id: <33E8FA7B.3E02@nospam.one.net>
Tad McClellan wrote:
> When I worked where I had no control over what was installed, I didn't
> want to appear clueless, nor did I want to wait hours for an answer
> that I could look up in less time than it took to type a Usenet
> article. So I needed current man pages.
>
> I just got a perl distribution from the 'net, unpacked it, snatched
> out the *.pod files and deleted the rest.
>
> Viola! I had my own local copies of current Perl man pages ;-)
> (and if you get 5.004, you'll get the Perl FAQs at the same time)
Have a copy of that (a relatively recent CD copy of the CPAN archive,
actually), but no place with sufficient breathing room to store it so I
can grep. However, the .html versions are there, so I can seek and find.
That helps some. :-) Man would be easier, though, and I am asking my
friendly sysadmin about installing that on our server (taking your other
post's hint but not so extreme unless his response calls for it ;-)
since lots of folks are using Perl there.
> : The code supplied by Mr. McClelland DOES turn on the light in that I
> ^ s/d//;-)
Oops! :-( Need to quit trying to post after long coding sessions. AND to
reinstall my real newsreader (I'd given up on keeping up with ng's some
time ago).
> : if I do it explicitly in the split command like this:
>
> : @fields = split(/\|/o, $data_row);
>
> : it works fine. If I define delimiter like so:
>
> : $delimiter="\|";
>
> If you put a:
> print "delimiter is '$delimiter'\n";
> here you will see what is wrong.
>
> Then you will realize that you wanted:
>
> $delimiter='\|'; # single quotes
>
> or
>
> $delimiter="\\|"; # escape the escape
Okay, checked out about single quotes vs double quotes in the camel book
and admit to feeling a bit sheepish about that one. But at least I
learned something!
> But, you can avoid the whole issue by doing the quoteing inside
> the split() regex:
>
> @fields = split(/\Q$d/o, $data_row);
I understand that part. What I wasn't sure about is what impact it would
have if the delimiter being used in a future use of this script happened
NOT to be a metacharacter? Would it matter?
> : Holly <my programs are never REALLY finished>
>
> Neither are anybody elses ;-)
Hey, I'm relatively new to Perl, but not to programming. ;-)
Thanks again for the learnings...
Holly
------------------------------
Date: Wed, 06 Aug 1997 09:38:05 -0400
From: dcolli@casc.com
Subject: CGI.pm Button and Input text problems
Message-Id: <33E87E3D.FBB@casc.com>
I have been a Unix perl user for the past 4 years and just started
using CGI.pm and also scripting for W95. I have two questions
regarding CGI.pm:
How do the variables get stored when reading input in the
middle of a form and lastly how do I make my buttons
perform launching of other perl scripts ?
Breifly, the code looks like this:
use CGI;
$query = new CGI;
I then start my html form code and then come to the user input:
print $query->textfield('Username');
print $query->textfield('Password');
It's these variables that I don't know how to access.
Lastly, my buttons look like this:
print $query->submit(`perl execute_this1.pl`,'Button1');
print $query->submit(`perl execute_this2.pl`,'Button2');
thanks,
Dean
------------------------------
Date: 6 Aug 1997 23:14:47 GMT
From: jcostom@shaft.sjis.com (Jason Costomiris)
Subject: Re: chop vs chomp
Message-Id: <slrn5ui1b7.27t.jcostom@dogbert.sjis.com>
On 6 Aug 1997 14:52:04 GMT, Jonathan Feinberg <jdf@pobox.com> wrote:
: Benarson.Behajaina@swh.sk said...
:
: > 1. chop and chomp
:
: chomp is "safe chop"; it only chops if the last character of the
: choppee is \n.
chomp does not only do \n. It does whatever $/ is set to. See
man perlfunc.
--
Jason Costomiris | Finger for PGP 2.6.2 Public Key
jcostom@sjis.com | "There is a fine line between idiocy
My employers like me, but not | and genius. We aim to erase that line"
enough to let me speak for them. | --Unknown
http://www.jasons.org/~jcostom
------------------------------
Date: Mon, 04 Aug 1997 18:01:33 +0300
From: Petri Backstrom <petri.backstrom@icl.fi>
Subject: Re: Conversion of Word Processing files
Message-Id: <33E5EECD.77B4@icl.fi>
Kaare Rasmussen wrote:
>
> The subject has been mentioned before, but I've never seen a proper
> answer.
>
> Is it possible to convert mainstream WP files (Word, WordPerfect, from
> different versions) between each other and to ASCII, tex, whatever?
Is there a part about Perl in your question somewhere? ;-)
Anyway, yes, it is possible (although depending on the file
formats there may be loss of formatting information - rarely
loss of content, but never say never... :-).
There are many such file conversion libraries available commercially
(two of the "larger" companies doing it were INSO and Mastersoft, but
last winter [Northern hemisphere context] INSO acquired Mastersoft).
Now, I don't remember if there are any conversion libraries
written in Perl, but if there are, you'll probably find them
through locations such as
http://www.perl.com/CPAN/
http://www.dejanews.com
http://altavista.digital.com
regards,
...petri.backstrom@icl.fi
ICL Data Oy
Finland
------------------------------
Date: Sun, 03 Aug 1997 06:06:42 GMT
From: kimmy@FIX-ME.iki.fi (Kim Holviala)
Subject: Re: Create E-mail with perl-script
Message-Id: <5s13nj$t8d$2@axe.wwnet.fi>
Laurijssen Dirk <laurijsd@se.bel.alcatel.be> once mumbled something
like this:
>I'm trying to send a message upon pushing a "send" button on a
>HTML-page.
>For now I use a perl-script to do so.
>The problem is that I write HTML-statements to the message but when I
>receive the message these statements aren't processed. (The tags stay
>visible).
You probably forgot the correct content-type, so print this along with
other headers in yer perl-script:
Content-Type: text/html
______________________________________________________________________
This garbage was written by Kim Holviala....
(You might wanna fix the email-addy before sending anything)
------------------------------
Date: Wed, 06 Aug 1997 15:49:17 -0400
From: Sean Henriques <shenriques@us.socgen.com-NOSPAM>
Subject: equivalent to map function
Message-Id: <33E8D53D.1D5E@us.socgen.com-NOSPAM>
all perl gurus!
I need to map the output of a function that works on an array to a new
array...is there a map function of some type that will do this??
thanks in advance!
sean
--
****************************************************************************
I'm allergic to SPAM...Please remove the NOSPAM- from my address before
replying to me!
SPAM = JUNK MAIL
Sean Henriques
mailto:shenriques@us.socgen.com
****************************************************************************
------------------------------
Date: 06 Aug 1997 09:32:26 -0400
From: Clark Dorman <clark@s3i.com>
Subject: Re: executing shell commands from perl. bug?!
Message-Id: <dzpqvwi6t.fsf@s3i.com>
Elias Pinto <ep05673@sbi.com> writes:
> After trying this few lines of code as part of a project, perl keeps
> exiting at the 'exec' commands without any warning. It compiles under
> 'perl -c' but at execution it doesn't even complaint! Even though there
> is a 'die' statement. It's strange because doesn't go beyong that point
> of execution.
>
> everything is in variables because of other parts of the program.
>
> $year = "1998";
> $dir = "./archive/".$year."/";
> $command = 'cp *.html '.$dir;
> exec $command
> or die "the copy func of *.html failed\n";
> exec 'cp some.report $dir'
> or die "the copy func of data... failed\n";
>
> I just want to execute these commands to the shell. What am I doing
> wrong? any ideas? email to ep05673@sbi.com
1. Use -w. -w is your friend.
2. Read the man page about exec(), and compare with system(). You probably
want system.
Actually, if you use -w it will tell you what the problem is. The
following is a script called lasdfg.pl
#!/home/dorman/bin/perl -w
exec "ls -l";
print "blah\n";
__END__
When I run this is says:
elmo:~ (9:29am) 65% lasdfg.pl
Statement unlikely to be reached at lasdfg.pl line 5.
(Maybe you meant system() when you said exec()?)
total 52
drwxr-xr-x 9 dorman 512 Jul 16 15:44 lib
drwxr-xr-x 4 dorman 512 Aug 6 09:29 mail
drwxr-xr-x 18 dorman 512 Jun 24 10:22 man
...
--
Clark Dorman "Evolution is cleverer than you are."
http://cns-web.bu.edu/pub/dorman/D.html -Francis Crick
------------------------------
Date: 6 Aug 1997 22:15:39 GMT
From: Bruce Gingery <bruceNoSpAm@pLeAsEgtcs.com>
Subject: Re: Have array, will (won't?) sort
Message-Id: <5sat2b$2if@horn.wyoming.com>
Dave,
Actually, your question exposes that you're new at Perl.
An array is a bucket of hash. It is not maintained in a ``sorted''
form. But that only addresses your question, not the meaning of it.
On Tue, 05 Aug 1997 20:18:46 -0400, in <33E7C2E6.3B82@indiana.edu>, D.F. Parkhurst <parkhurs@indiana.edu> wrote:
> I'm new at Perl, so this is probably an easy question.
> I have a program that was translated from awk to perl. It
> includes an array $r ($r{1}, etc.) of floating point numbers that
> I want to sort.
> The llama book shows a numeric sort in the form
> @sortedlist = sort { $a <=> $b } @unsortedlist,
Yes, and if all you need is a sorted list of the values
that will do it for you. The ``list'' to sort can be returned
with the ``values'' primitive.
If what you need is a sorted list of the existing keys,
similarly, the ``list'' to sort can be returned with the
``keys'' primative. This will allow you to iterate through
the resulting sorted keys, and access their related values
in the original array.
> but that sorts a list and produces a list.
> How do I sort an array of numbers to get an array?
I *think* that's what you were asking, with a sort of the
keys of the array, but ...
You can also build a list of sortable structures that
contain key and value. Inefficient in most cases, but closest
to what you asked.
Bruce Gingery`
------------------------------
Date: 6 Aug 1997 12:50:38 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: Help! - Reformatting Date
Message-Id: <5s9ruu$emo@news-central.tiac.net>
In article <vtolbert-ya02408000R0408971456100001@news.mindspring.com>,
Victor Tolbert <vtolbert@mindspring.com> wrote:
>The following expression
> * chop($today = `/usr/bin/date`);
>returns
> * Mon Aug 4 13:22:09 EDT 1997
>
>What I would rather have is a simple date format which can be easily
>imported into a database. Such as: 8/4/1997 or maybe even Aug 4, 1997.
If you have the POSIX module then you might be able to use strftime to get
dates like 08/06/1997 ('%m/%d/%Y') or Aug 06, 1997 ('%b %d, %Y') or there
are several Date and Time manipulation modules in the Comprehensive Perl
Archive Network (CPAN) which can be reached via http://www.perl.com/CPAN/
Alternatively you can use a printf string oan operate on the list returned
by localtime (see the perlfunc manual page) - remembering that the year
needs to have 1900 added to it.
Hope this helps,
Mike
--
mike@stok.co.uk | The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/ | PGP fingerprint FE 56 4D 7D 42 1A 4A 9C
http://www.tiac.net/users/stok/ | 65 F3 3F 1D 27 22 B7 41
stok@psa.pencom.com | Pencom Systems Administration (work)
------------------------------
Date: Wed, 06 Aug 1997 01:17:45 +0000
From: Jeffee Kiser <#j.kiser@ix.netcom.com>
Subject: installation problems
Message-Id: <33E7D0B9.5DAB@ix.netcom.com>
I am in the process of trying to install a local copy of the latest
release of Perl on my Sun Workstation (sunos 4.1.4). Our sys/admin will
not update us from 5.001 without more requests and I'm the only person
with any use of the newer revs. Anyhow, no matter which cc compiler I
use on our network, the install crashes at the same place every time;
when I run make. It gets to the point where it tries to compile
miniperlmain and I get library errors referring me to a slew of
mathematic functions (_cos, _atan, etc.). No matter what flags I set,
it always dies at this part. Has anyone out there ran into this problem
or possibly know what kind of bonehead thing I am doing wrong. Any help
would be greatly appreciated. Thanks
Jeff Kiser
jeffk@oaktech.com (work)
j.kiser@ix.netcom.com (home)
(408) 328-6832
------------------------------
Date: Wed, 06 Aug 1997 03:01:42 -0600
From: kerryg@delta.net
Subject: Re: Microsoft violating Perl license? (was Re: arrogant #*(@#)
Message-Id: <870854055.4945@dejanews.com>
In article <5s7nak$hs1$1@as1000.javanet.com>,
"Michael B. Klein" <michael@kbk.org> wrote:
>
> Unfortunately, I don't *think* this is an option if you're using Microsoft
> IIS and want to build ASP files using ActiveWare's PerlScript active
> scripting engine. I feel kind of stuck here, because I want a full perl
> release (not just what ActiveWare & MS decide I should have), but I really
> like the PerlIIS connector and especially the scripting engine.
>
> Unless I'm mistaken and there's a way to get the PerlScript engine to work
> with a roll-your-own build...
A much better alternative is to use the standard Perl32 and interface it
with Tyrell Software's PerlScript. Check it out at
http://www.perlscript.com -Kerry
-------------------==== Posted via Deja News ====-----------------------
http://www.dejanews.com/ Search, Read, Post to Usenet
------------------------------
Date: Wed, 06 Aug 1997 08:07:23 GMT
From: tor@kmd.dk (Torfinn Keringen)
Subject: Need help with split
Message-Id: <33e82cb5.182006417@news>
Hi
This works ofcourse fine
($first,$second,$third) = split(/\+/);
and this works fine
($first,$second,$third) = split(/\$/);
but what if I want to use a variable:
$separator = "+" or $separator = "$"
Is this possible, and what is the syntax?????
[($first,$second,$third) = split("What do I put here");]
Thanks Torfinn
tor@kmd.dk
------------------------------
Date: Wed, 06 Aug 1997 03:01:46 -0600
From: Marcus Engene <marcus@student.adb.gu.se>
Subject: Perl daemon program dies while sleeping
Message-Id: <870854171.5009@dejanews.com>
Hi. I've got this obscure problem I can't quite understand.
I & two others are programming a simple webspider in perl . The
general
structure of it is something like:
* a daemonprogram - listens to a socket (IO::Socket) for
cgi-connections
and to its own children (IPC::Open2) using IO::Select.
* master program, as a child to the daemon. It organizes the search
and
makes sure that not a single domain is getting to much requests etc.
it communicates with its children through a Select on open2:ed
streams.
* A searchprogram to interface to existing searchengines to get
links to start with.
* a slave, that receives a webpage, analyses it and gives the
information to master (through STDOUT, STDIN).
Now, everything works fine, except for the fact that the daemon just
dies
after a while (when searching. Not otherwise). It gives no error
information, neither from perl nor the OS.
I know it consumes hugh amounts of memory and takes a while, so I've
disabled any limits in the UNIX-shell before starting it up (limit,
ulimit
stuff). I've tried it under SunOS 5.5.1 and Linux 2.0.29. Using a lot
of
paranoia-prints, I've noticed that the daemon receives a INT signal
(which
the children inherits & dies of). If I IGNORE that signal, it gets a
SIGKILL (9) instead. I've also disabled the mSQL-interface to it, but
it
didn't help.
In the daemon, the error occures in the sleep of the select-statement,
which is logical since most time is spent in the timeout sleep. I have
made the enormously paranoid act "making timeouttime 0 and do a sleep
by myself", which produced the very same error.
If anyone has any idea of what it can be, or what to try out etc,
please
say it.
Using 5.004_01 in Linux, and 5.003 under solaris.
Regards, Marcus
-------------------==== Posted via Deja News ====-----------------------
http://www.dejanews.com/ Search, Read, Post to Usenet
------------------------------
Date: Wed, 06 Aug 1997 09:40:00 +0200
From: Doug Seay <seay@absyss.fr>
To: Carol Lynn Smith <carols@sdt.com>
Subject: Re: Perl Truncation
Message-Id: <33E82A50.34E324C5@absyss.fr>
Carol Lynn Smith wrote:
>
> How do I chop off at 50 characters not including a return or ^I?
This is untested, but it should do basically what you want. Nothing
fancy here, this is the same basic approach most people would use in C,
Basic or whatever. Just loop through each character of $string and
decrement the $remaining counter except for stuff we're skipping (return
and tab). Once all the characters have been found, just return those
that matched.
sub first_X_skipping_Y($$$)
{
my ($string, $remaining, $skip) = @_;
my $index;
for ( $index=0 ; $index<length($string) && $remaining>0 ; $index++ )
{
my $ch = substr($string, $index, 1);
$remaining-- unless ( $ch =~ m/$skip/ );
}
substr($string, 0, $index);
}
- doug
------------------------------
Date: 7 Aug 1997 00:09:09 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Perl Truncation
Message-Id: <5sb3n5$og5$1@marina.cinenet.net>
Carol Lynn Smith wrote:
> How do I chop off at 50 characters not including a return or ^I?
$string =~ s/(^[^\n\t]{0,50}).*/$1/;
That's assuming you mean "Given a string, reduce it to a string ending
just before the first tab or newline, or at the 50th character."
---------------------------------------------------------------------
| Craig Berry - cberry@cinenet.net
--*-- Home Page: http://www.cinenet.net/users/cberry/home.html
| Member of The HTML Writers Guild: http://www.hwg.org/
"Every man and every woman is a star."
------------------------------
Date: Wed, 06 Aug 1997 18:37:10 -0600
From: ajt@terlecki.demon.co.uk
To: ajt@terlecki.demon.co.uk
Subject: Possible Perl FAQ mistake about record separators?
Message-Id: <870864029.9068@dejanews.com>
Is there a mistake in the FAQ for the section entitled "How can I read
in a file by paragraphs?" in part 5 or am I just not understanding
record separators properly? To quote:
"Use the $\ variable (see the perlvar manpage for details). You can
either set it to "" to eliminate empty paragraphs ("abc\n\n\n\ndef",
for instance, gets treated as two paragraphs and not three), or "\n\n"
to accept empty paragraphs."
Surely you need to modify the input record separator $/ to modify how
records are read in, and not $\ which is the output record separator.
Or, as I said before, am I just not understanding record separators
properly?
--
Anthony Terlecki
ajt@terlecki.demon.co.uk
-------------------==== Posted via Deja News ====-----------------------
http://www.dejanews.com/ Search, Read, Post to Usenet
------------------------------
Date: 6 Aug 1997 22:54:19 GMT
From: rns@ariel.ucs.unimelb.EDU.AU (Robert Sturrock)
Subject: Pre-forking server example needed
Message-Id: <5savar$hn1$1@izvestia.its.unimelb.edu.au>
Hi.
Does anyone have any examples of server code (in Perl) that "pre-fork()s"
a number of child processes, and then uses those children to service
client requests when they arrive. Similar to the way servers like
squid operate, but in Perl?
TIA.
/r.
--
Robert Sturrock _-_|\ E-mail: rns@its.unimelb.edu.au
Information Technology Services / \ Phone: +61 3 9344 7996
The University of Melbourne \_.-.*/ Fax: +61 3 9347 4803
Parkville 3052, AUSTRALIA v
------------------------------
Date: 6 Aug 1997 07:50:11 GMT
From: "Bernard Gibbons" <bgibbons@nsp-inc.com>
Subject: Problems Appending To A File
Message-Id: <01bca23d$73fa0080$508f5dcf@questrec.vip.best.com>
Help! What am I doing wrong?
My ISP tells me I can place cgi files anywhere so long as they have the
extension .cgi and that seems to work fine until I want to write (append)
to a file.
I have the .cgi program in my public_html directory which has permissions
of 711 as set by my ISP. My .cgi executables (which are in perl) have
permissions of 750 as per my ISP's instructions.
I want to append data to jobs.dat in the /files sudirectory.
I created the /files subdirectory with permissions 766. So anybody should
be able to write to it.
I then created an "empty" text file jobs.dat with permissions set to 766 so
the same applies.
So why doesn't this .cgi extract work which is in my public_html directory?
#!usr/local/bin/perl5
print "<HTML><HEAD><TITLE>Test</TITLE></HEAD><BODY>";
print "<H2>Opening File To Append</H2>";
open (OUT, ">>files/jobs.dat") || die "Can't Open Output File";
print "<H2>Opened</H2>";
print "</BODY></HTML>";
My first 2 print statements work and that is all. I don't get the "die"
statement or the last print statement. So what is happening?
If anybody has any ideas I would love to hear them.
Please respond to:
Bernard Gibbons
bernard510@hotmail.com
------------------------------
Date: Mon, 04 Aug 1997 15:09:15 GMT
From: roswell@umbc.edu (Marjorie Roswell)
Subject: Re: Request help extracting acronyms
Message-Id: <33e5ea2e.4177625@news>
Thank you very much, Daniel and Mike!
Now there is a special case that I want to consider.
If the acronym is used at the end of the sentence, my addition will
remove the final period if there is only one period. Thus, it will
return "UNICEF" instead of "UNICEF." in the sentence
"Please support UNICEF."
Now, wouldn't it be nice if U.S.A. sorted *after* UNICEF? Suggestions
are welcome! Once we get this last piece ironed out, (or even if we
don't) may I submit it to the FAQ? (email:
perlfaq-suggestions@perl.com).
How do Swedish acronyms work, Mike?
- Margie
_____________________________
#!/usr/local/bin/perl5
# Search a text file for acronyms
while (<>) {
next if $_ eq uc($_);
$h{$1} = 1 while /([A-Z][A-Z.]+)/g;
}
foreach $key (sort keys %h) {
chop($key) if $key =~ tr/.// ==1; #remove final period if only one.
print "$key\n";
}
_________________________________________________________
Marjorie Roswell, Spatial Analyst
UMBC Center for Health Program Development and Management
1000 Hilltop Circle Fx: (410)455-6850
Baltimore, MD 21250 E: roswell@umbc.edu
Ph: (410)455-6802 http://umbc.edu/~roswell/mipage.html
_________________________________________________________
------------------------------
Date: Wed, 6 Aug 1997 01:46:04 GMT
From: ced@bcstec.ca.boeing.com (Charles DeRykus)
Subject: Re: sleep not mixing well with other signal handlers
Message-Id: <EEGy8t.A30@bcstec.ca.boeing.com>
In article <5s7mvl$3np@gap.cco.caltech.edu>,
Shimpei Yamashita <shimpei@socrates.caltech.edu> wrote:
> As I understand from perlfunc man pages, sleep should not be used
> along with signal handlers for SIGALRM, but there shouldn't be any
> problems installing signal handlers for other signals, right?
>
> #! /usr/bin/perl
>
> $SIG{CHLD}=\&hee;
>
> if ( ($child=fork) < 0 ) {
> die "Error: could not fork!\n";
> }
> if ( ($child > 0) ) {
> sleep 2;
> kill "STOP", $child;
> print "suspension done\n";
> sleep 10;
> print "sleep done\n";
> } else {
> for($i=0;$i<99999999;$i++) {
> print;
> }
> }
>
> sub hee {
> if (kill 0, $child) {
> print "$child suspended\n";
> } else {
> print "$child dead\n";
> wait;
> }
> }
>
> Eventually I'd like to write code in which the parent will
> periodically suspend the child, do some stuff, and turn the child back
> on. Right now the code should just let the child run amok for two
> seconds before the child gets suspended, after which the parent
> sleeps for 10 seconds and exits (upon which the children should
> die also).
>
> The problem is that the second "sleep 10" statement is not being
> honored: after two seconds, the program prints
>
> suspension done
> <some number> suspended
> sleep done
>
> all at once and exits. If I take out the kill statement, it works just
> as expected. What gives? I'm pretty new at this signals programming
> business, so it is possible that I'm doing something entirely wrong.
> I'd appreciate some help.
>
> This is on perl 5.004_01. I've run the script on Linux 2.0.30 (Intel
> and PowerPC) and Solaris 2.5.1 (SPARC) with identical results, so
> I don't think it's a quirk in a particular OS.
>
sleep is often implemented in turns of a signal alarm I believe.
Unfortunately, some signal clobbering can occur if signals are
received while an existing signal is being handled. There
appears to be something of this ilk in the interaction of the
stop and alarm signals although I can't say exactly what.
One CPU intensive possibility is to substitute this for the
second sleep:
my $start = time(); 1 until time() - $start == 10;
Another expensive solution:
sleep 10 unless fork;
wait;
Here's something I modified which appears to work by blocking
receipt of the alarm signal while the SIGSTOP is sent.
Sending the STOP signal to the local process first may
be heavy handed too though.
$SIG{STOP} = \&reaper;
sub reaper {
my $mask = new POSIX::SigSet SIGALRM;
my $action = new POSIX::SigAction "reaper", $mask;
sigaction SIGSTOP, $action or die $!;
kill 'STOP', $kid;
};
...
...
kill 'STOP', $$;
sleep 10;
$SIG{STOP} = 'DEFAULT';
HTH,
--
Charles DeRykus
ced@carios2.ca.boeing.com
------------------------------
Date: 6 Aug 1997 23:53:29 GMT
From: news@bofh.com (Jot Powers)
Subject: Re: What means --> Can't call method "xxxxxxx" on unblessed reference ...?
Message-Id: <5sb2pp$qoq$1@gazette.corp.medtronic.com>
[emailed and posted]
>-------
>Can't call method "AddHeader" on unblessed reference at pop4.pl line 88,
><SOCK2> line 29.
>-------
>{Who can bless it?}
man perldiag yields...
Can't call method '%s' on unblessed reference
(F) A method call must know in what package it's
supposed to run. It ordinarily finds this out from the
object reference you supply, but you didn't supply an
object reference in this case. A reference isn't an
object reference until it has been blessed. See the
perlobj manpage.
>I can send a source if somebody is interested to help...
You might also try reducing this program to as small an example
as possible, and post that.
HTH
--
Jot Powers news@bofh.com
Unix System Administrator
"Sometimes you just have to grab the bull by the tail and face the situation."
------------------------------
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 818
*************************************