[8459] in Perl-Users-Digest
Perl-Users Digest, Issue: 2076 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Mar 11 16:09:52 1998
Date: Wed, 11 Mar 98 13:00:29 -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, 11 Mar 1998 Volume: 8 Number: 2076
Today's topics:
$IFS variable eugene@vertical.net
Re: $IFS variable (Chip Salzenberg)
Re: ?name=A+B (Craig Berry)
Re: Brand new and completely bewildered!!! (Martin Vorlaender)
Re: c.l.p.mod and TPI (John Stanley)
Re: c.l.p.mod and TPI (Chris Nandor)
Re: Calling a CGI inside another CGI (Craig Keefner)
Re: Checking filedate in perl <dean@tbone.biol.sc.edu>
Re: Checking filedate in perl (Martin Vorlaender)
Compiler Alpha3: compile the C on Windows & Mac (Jacques Le Marois)
Re: Easy regex question <hsommer@micro.ti.com>
Re: Easy regex question <jdf@pobox.com>
Re: Easy regex question (Craig Berry)
Re: Easy regex question (Abigail)
Exec perl scrip from java problems <men@otter.hpl.hp.com>
Re: HELP IN A PERL SCRIPT (Craig Berry)
Re: HELP IN A PERL SCRIPT <mkahn@vbe.com>
Re: How do I rename a file using perl (Abigail)
indirect-object problem solved stvhoof@netvision.net.il
Need help with PERL script amin@wessels.com
Re: nslookup? <jsd@hudsucker.gamespot.com>
Re: Perl & Cookies: How do I delete once a person leave (brian d foy)
Re: PID of process launched in unix system? <hsommer@micro.ti.com>
Re: printf / unlink / ?: <jdf@pobox.com>
Running scripts under different user ID on UNIX <joe.tully@virgin.net>
Re: sorting [FAQ] (Mike Stok)
Re: sorting <jdf@pobox.com>
Spitting out MIME types <object01@cc.gatech.edu>
Re: splice -- useful uses? (Michael Fuhr)
sytem grep what does it returns <creed@osd.ulaval.ca>
Re: sytem grep what does it returns (Richard Bellavance)
What command Calls a prog on the web? (Psiberjack)
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 11 Mar 1998 12:42:55 -0600
From: eugene@vertical.net
Subject: $IFS variable
Message-Id: <6e6lss$ql6$1@nnrp1.dejanews.com>
perlsec reccomends to set $IFS as follows:
$ENV{'IFS'} = '' if $ENV{'IFS'} ne '';
Can someone explain why this is necessary?
Thanks.
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/ Now offering spam-free web-based newsreading
------------------------------
Date: Wed, 11 Mar 1998 20:04:07 GMT
From: chip@mail.atlantic.net (Chip Salzenberg)
Subject: Re: $IFS variable
Message-Id: <6e6qr1$97a$1@cyprus.atlantic.net>
According to eugene@vertical.net:
>perlsec reccomends to set $IFS as follows:
> $ENV{'IFS'} = '' if $ENV{'IFS'} ne '';
>Can someone explain why this is necessary?
Actually, I recommend C<delete $ENV{IFS}>. See the man page for
the "sh" program for info.
--
Chip Salzenberg - a.k.a. - <chip@pobox.com>
"I brought the atom bomb. I think it's a good time to use it." //MST3K
-> Ask me about Perl training and consulting <-
Like Perl? Want to help out? The Perl Institute: www.perl.org
------------------------------
Date: 11 Mar 1998 18:48:58 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: ?name=A+B
Message-Id: <6e6maq$pbt$4@marina.cinenet.net>
Holly Sommer (hsommer@micro.ti.com) wrote:
: Arnoud de Jong wrote:
: : How can I change the <space> to <+>?
:
: To change one whitespace (space, tabs, etc.) to one plus sign:
:
: s/\s/\+/; (or s/ /\+/; for just an actual space)
No need to escape the + in the substitute part of s///, and the original
poster wanted *all* spaces converted, so
s/\s/+/g;
is what's really needed.
---------------------------------------------------------------------
| 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, 11 Mar 1998 19:18:51 +0100
From: martin@RADIOGAGA.HARZ.DE (Martin Vorlaender)
Subject: Re: Brand new and completely bewildered!!!
Message-Id: <3506d58b.524144494f47414741@radiogaga.harz.de>
Bjoern Guenzel (guenzel.p1@usa.net) wrote:
: I have downloaded several CGI-documentations and tutorials, but I
: haven't come across 'statelessness'. What does it mean? Maybe then I
: finally could make some sense of all this stuff :-)
: I admit that I haven't got CGI.pm yet, I promise it's the next thing
: I'll get.
The term "statelessness" describes the fact that every HTML transaction
(GET, HEAD, POST, PUT, DELETE and the answer to the request) is on its own,
i.e. not related to previous or following transactions.
cu,
Martin
--
| Martin Vorlaender | VMS & WNT programmer
Ceterum censeo | work: mv@pdv-systeme.de
Redmondem delendam esse. | http://www.pdv-systeme.de/users/martinv/
| home: martin@radiogaga.harz.de
------------------------------
Date: 11 Mar 1998 20:20:16 GMT
From: stanley@skyking.OCE.ORST.EDU (John Stanley)
Subject: Re: c.l.p.mod and TPI
Message-Id: <6e6rm0$c9s$1@news.orst.edu>
In article <Pine.OSF.3.95.980311102252.11118M-100000@primal.ucdavis.edu>,
Jason Christian <jason@primal.ucdavis.edu> wrote:
>Okay. Then take it as a reply to your just-posted article, asking Randal
>to prove his contention that c.l.p.announce doesn't allow some sort of
>announcement. You think he's wrong, I think he's wrong, it may well be
>that only Randal holds that interpretation...but Randal has announced
>that he will post those articles.
Yes, and my response was "very good."
>Upon the advice of <some nefarious
>cabal>, sure...but that is precisely my point. Randal as c.l.p.announce
>moderator can seek whatever advice he wants...that of the Nefarious
>Cabal, left-handed Death-Row inmates, my three-year-old daughter, even
>you or me.
I didn't say he couldn't.
>Evidently Randal's announced decision to seek the help of
>the Nefarious Cabal, rather than some other group, or instead of relying
>on his own devices, disturbs you.
Evidently not. He doesn't need their "advice", but I didn't tell him he
couldn't get it.
>Alas, your disturbance on this matter
>at least is entirely irrelevant: c.l.p.announce has already been
>created, with Randal as despot^H^H^H^H^H^Hmoderator.
Your refernce to him as a despot is your own invention. Please stop
implying that I referred to him that way.
>btw, didn't you promise to killfile me a couple of months ago?
I don't have anybody in my killfile. I killfile topics, not people. I
judge what is said, not who says it.
------------------------------
Date: Wed, 11 Mar 1998 12:48:45 -0500
From: pudge@pobox.com (Chris Nandor)
Subject: Re: c.l.p.mod and TPI
Message-Id: <pudge-1103981248450001@ppp-3.ts-1.kin.idt.net>
In article <6e6d9u$ulk@eyrie.org>, kate@eyrie.org (Kate Wrightson) wrote:
# I can certainly understand David' interpretation. It's not necessary to
# call him a liar.
I did not call him a liar, I said "do not spread lies". Please do not
spread lies about what I said. :)
--
Chris Nandor pudge@pobox.com http://pudge.net/
%PGPKey=('B76E72AD',[1024,'0824 090B CE73 CA10 1FF7 7F13 8180 B6B6'])
#== MacPerl: Power and Ease ==#
#== Publishing Date: Early 1998. http://www.ptf.com/macperl/ ==#
------------------------------
Date: Wed, 11 Mar 1998 20:30:46 GMT
From: keefner@kinetic.com (Craig Keefner)
Subject: Re: Calling a CGI inside another CGI
Message-Id: <3506f1b6.14395669@news.visi.com>
On Sun, 08 Mar 1998 11:08:28 GMT, brian@brie.com (Brian Lavender) wrote:
Check out my mini map server code where you will find what I
>am talking about. http://www.brie.com/coinduperl/ as far as one cgi
>activating another cgi. Oh yeah, check out
>comp.infosystems.www.authoring.cgi .
I have a similar question and I've looked over those
materials(& more).
I have two perl scripts for an app and the second
one just processes an Oracle query. In my first
I do lots of user queries and use cgi.pm and submit
to pass the info (once fully collected) to the
Oracle pl script.
In some cases I have enough info and assuming I
can carry my paramters/information to the Oracle
pl, I just want to go there and do that.
I've tried exec("oracle.pl"; but I haven't
got it to work yet without a server error.
It works fine on a normal submit/post.
Craig
------------------------------
Date: 11 Mar 1998 14:16:05 -0500
From: Dean Pentcheff <dean@tbone.biol.sc.edu>
Subject: Re: Checking filedate in perl
Message-Id: <87soopghsa.fsf@tbone.biol.sc.edu>
news@NOSPAMgb-design.com (Bjorn Malmberg) writes:
> On 11 Mar 1998 11:14:27 -0500, Dean Pentcheff <dean@tbone.biol.sc.edu>
> wrote:
>
> <snip>
> >Have you considered reading the Perl documentation? Several megabytes
> >of it came with your Perl installation. Filetest operators are
> >documented in the perlfunc manual section.
>
> I am reading the manuals that came with my perl installation! But
> maybe I didn't find just this!! Will search better next time!
Sorry to have sounded so curt, but really, truly, Usenet is not a good
place to search for answers to questions that are already in the
documentation. The "grep" program is a wonderful tool for searching
simple documentation. It is available compiled for NT
>
> <snip>
> >No. You want to use Usenet to get help, but you don't want to read
> >Usenet? And you want me to edit your email address for you? You're
> >kidding.
>
> I read from this group too!! But I can't be online all the time to
> read it! It cost to much here in Sweden!
Let me see if I've got this straight now: Usenet is so expensive to
you that you're reluctant to use it. But you'd like me to spend my
time giving you an answer and editing your email address to send it to
you. No.
>
> I use the NOSPAM thing in my email address since I don't want any SPAM
> in my inbox! You should do that too!!!
No. The purpose of an email reply address is to function as an email
reply address. Period. If you have trouble with email spam, the last
thing you can count on is for people helping you out (at no charge) to
take extra pains to send you the help. I will not obscure my email
address. I do use aggressive anti-spam filters that work very well.
If you're interested, the core of what I use is available at:
<URL:http://www.best.com/~ariel/nospam/>. It is extensively documented
and remarkably effective.
> Why do you send this kind of message to this newsgroup anyway??
> Send it to my email address if you have any complaints about what I
> do!
You do not provide a functioning email address.
>
> For all the others:
>
> Sorry for waisting your bandwidth with this unuseful message, won't do
> it again!
> ____________________________________________________
> Take away the word NOSPAM to make an email reply! :)
No.
-Dean
--
N. Dean Pentcheff <pentcheff@acm.org>
Biological Sciences, Univ. of South Carolina, Columbia SC 29208 (803-777-7068)
------------------------------
Date: Wed, 11 Mar 1998 19:21:45 +0100
From: martin@RADIOGAGA.HARZ.DE (Martin Vorlaender)
Subject: Re: Checking filedate in perl
Message-Id: <3506d639.524144494f47414741@radiogaga.harz.de>
Bjorn Malmberg (news@NOSPAMgb-design.com) wrote:
: OK, so I need to check a file when it was written now... if the file
: is not written that day, the perl script should write to it, but if it
: was written the same day, not write to it... that should be no
: problem, I think.. however, how could I check when the file was
: written last time in perl?
perldoc -f stat
cu,
Martin
--
| Martin Vorlaender | VMS & WNT programmer
Ceterum censeo | work: mv@pdv-systeme.de
Redmondem delendam esse. | http://www.pdv-systeme.de/users/martinv/
| home: martin@radiogaga.harz.de
------------------------------
Date: Wed, 11 Mar 1998 20:13:43 GMT
From: jlm@geneanet.orgenlevemoi (Jacques Le Marois)
Subject: Compiler Alpha3: compile the C on Windows & Mac
Message-Id: <3508efb3.36048073@news.call.oleane.com>
Hello,
I succeed in using the Alpha 3 compiler of Malcolm on Linux.
I get C code and compile it successfuly with cc_harness.
Now, is there anyone who succeed to compile this C code on Windows and on
Macintosh ?
What's the procedure ?
(i don't know well how to use a C compiler).
Thanks,
Jacques.
------------------------------
Date: Wed, 11 Mar 1998 12:42:15 -0600
From: Holly Sommer <hsommer@micro.ti.com>
Subject: Re: Easy regex question
Message-Id: <3506DB07.862F93EA@micro.ti.com>
I think what you are after is /(teapot)?/ (parens) group...
[brackets] create a character class like [a-zA-Z]
-Holly
------------------------------
Date: 11 Mar 1998 14:04:10 -0500
From: Jonathan Feinberg <jdf@pobox.com>
Subject: Re: Easy regex question
Message-Id: <zpixrqvp.fsf@news.concentric.net>
Chris <chris@surewould.com> writes:
> How the heck do I match a word?
> My perl book is packed away in my brother's basement, the perlop
> help page doesn't help with this, and I looked at www.perl.org for
> an FAQ but I couldn't find one mentioned. Thanks, Chris
There are not one, but *ten* FAQs included with every perl
distribution. They are called perlfaq, perlfaq1-perlfaq9. There is
also an entire document that deals with regexes: perlre. You should
begin any documentation search by glancing at the document called
simply "perl". It tells you where all of the other documentation
lives.
You match a word by asserting word boundaries:
/\bword\b/
Word boundaries are explained in perlre. HTH.
--
Jonathan Feinberg jdf@pobox.com Sunny Brooklyn, NY
------------------------------
Date: 11 Mar 1998 19:15:00 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Easy regex question
Message-Id: <6e6nrk$pbt$5@marina.cinenet.net>
Holly Sommer (hsommer@micro.ti.com) wrote:
: I think what you are after is /(teapot)?/ (parens) group...
: [brackets] create a character class like [a-zA-Z]
Of course, be aware that /(teapot)?/ as a standalone regex will always
match any string at all, at the beginning of the string. Since the entire
'teapot' string is optional, if 'teapot' isn't the first char sequence in
the string, a match will be made on the nothingness before the first char
instead.
---------------------------------------------------------------------
| 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: 11 Mar 1998 20:02:38 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Easy regex question
Message-Id: <6e6qku$lj0$1@client2.news.psi.net>
Chris (chris@surewould.com) wrote on 1653 September 1993 in
<URL: news:3506D449.7AC4342@surewould.com>:
++ I have a regex question that for some reason is stumping me:
++
++ How the heck do I match a word?
++
++ For example, I want to check for 0 or 1 instances of the word 'teapot'.
++ /teapot?/ doesn't work, since it checks for 'teapo' and an optional t.
++ /[teapot]/ is of course also not quite right. What the heck is my
++ problem? My perl book is packed away in my brother's basement, the
++ perlop help page doesn't help with this, and I looked at www.perl.org
++ for an FAQ but I couldn't find one mentioned.
man perlre
Abigail
--
perl -we 'print split /(?=(.*))/s => "Just another Perl Hacker\n";'
------------------------------
Date: 11 Mar 1998 18:57:18 GMT
From: "Marc Nijdam" <men@otter.hpl.hp.com>
Subject: Exec perl scrip from java problems
Message-Id: <01bd4d1f$836c4e00$6ea20f0f@ispdemo1>
Hi,
I've written a java class which does a Runtime.getRuntime().exec call
to start a perl subprocess. I create all well known environment
variables to pass into the exec call (eg. PATH, WINDIR, WINSYSDIR,
SystemRoot, etc), so that perl can find the executables it needs.
The perl script does a call to an executable (which is on the PATH)
and parses the output.
The perl script works fine from the commandline but fails mysteriously
when execced from java. Judging from the return value of open (1) the
process runs fine (same return value as when run from the command
line), but the pipe fails to read any data... Here's the test script:
---
my $status = open(CMD,"myexec 2>&1 |");
print "Status = $status\n";
while (<CMD>) {
print "Results of command are: $_";
}
close(CMD);
Run from command line printd:
Status = 1
Results of command are: data1
When execced from java's Runtime:
Status = 1
Results of command are:
---
Anyone have any idea? I'm completely at a loss here. Does it have
something to do with perl being sarted non-interactive?
Any suggestions greatly appreciated!!!
Cheers,
Marc Nijdam
------------------------------
Date: 11 Mar 1998 18:43:52 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: HELP IN A PERL SCRIPT
Message-Id: <6e6m18$pbt$3@marina.cinenet.net>
wsayegh@lynx.neu.edu wrote:
: I am not a PERL professional, and I need the following help. How could I do
: the following:
:
: Store the first 140 characters of each line (line by line) in a variable, and
: the rest of the characters (141+) in another variable. If the first character
: in the variable is equal to X the do so else do that....
perldoc -f substr
perldoc -f unpack
---------------------------------------------------------------------
| 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, 11 Mar 1998 13:30:20 -0600
From: Mark Kahn <mkahn@vbe.com>
Subject: Re: HELP IN A PERL SCRIPT
Message-Id: <3506E64C.41466BB3@vbe.com>
Is it the start of another semester?
------------------------------
Date: 11 Mar 1998 20:08:06 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: How do I rename a file using perl
Message-Id: <6e6qv6$lj0$2@client2.news.psi.net>
arzoo@ids.net (arzoo@ids.net) wrote on 1653 September 1993 in
<URL: news:6e6g20$m32$1@nnrp1.dejanews.com>:
++ I want to rename a file using a PERL script that takes an input from a HTML
++ form and renames according to that input. I have almost everyting working
++ except the actual rename command itslef. Here is what I set up before the
++ rename itslef. The names have been changed to protect the innocent.
Ah, yes, that's one of the mysteries of Perl. To rename a file, you
actually don't use a function called rename () (you did notice that perldoc
-f rename only resulted in an ascii image of a funny face, didn't you?),
but it the highly obscure function littlepurpledinosaur (), which takes 5
arguments: your name, your credit card number, the new name of the file,
the expiration date, and the old name of the file, in that order.
This function was created when Barney was still releasing Perl.
HTH. HAND.
Abigail
--
perl -we 'print split /(?=(.*))/s => "Just another Perl Hacker\n";'
------------------------------
Date: Wed, 11 Mar 1998 13:32:45 -0600
From: stvhoof@netvision.net.il
Subject: indirect-object problem solved
Message-Id: <6e6oqa$sqt$1@nnrp1.dejanews.com>
I wrote:
> >I am using CGI.pm. I have a line that says
> >
> >$foo = $cgi->param('bar');
> >
> >It works fine. Just as an experiment to increase my understanding of
> >using objects in Perl, I tried changing it to:
> >
> >$foo = param $cgi 'bar';
> >
> >This caused a syntax error. Why is this? Aren't "object-oriented" and
> >"direct object" syntax supposed to do the same thing?
Just thought I'd post the answer I've found to my own problem! While no one
here on this NG came up with the exact solution, your comments were helpful in
getting me to think along the right lines. It turned out to be a problem in
my "use" statement. I had written:
use CGI(:standard);
This turns out to interfere with "indirect object" syntax, because it causes
the name "param" (among other names) to be exported into my namespace, thus
causing the syntax error when i try to use "indirect-object" syntax. When I
changed the line to:
require CGI;
I was able to use the "indirect-object" syntax with no problem. I'm not sure
if this issue is a bug or an inherent limitation caused by some ambiguity in
the syntax between normal function calls and "indirect-object" usage.
Anyway thanks for your help...
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/ Now offering spam-free web-based newsreading
------------------------------
Date: Wed, 11 Mar 1998 20:39:12 GMT
From: amin@wessels.com
Subject: Need help with PERL script
Message-Id: <3506f500.96825411@client.ce.news.psi.net>
Hey I need help.
I am trying to write a PERL program that checks my email as it comes
(on a UNIX machine), and clips the header and a number of lines from
the message body. Then it resends the mail to another address. Then
clips the remaining text of the message body. I prefer to put the
lines to be re-mailed in the subject line, but not important.
Example:
header <--- ignore (will always be the same)
message body line1 <--- ignore (will always be the same)
message body line2 <--- ignore (will always be the same)
message body line 3 <--- ignore (will always be the same)
message body important line 1 <--- resend to new email address
message body important line 2 <--- resend to new email address
message body important line 3 <--- resend to new email address
message body line 4 <--- ignore (will always be the same)
message body line n <--- ignore (will always be the same)
Any ideas? Can you help me??
Many thanks!
------------------------------
Date: 11 Mar 1998 19:24:08 GMT
From: Jon Drukman <jsd@hudsucker.gamespot.com>
Subject: Re: nslookup?
Message-Id: <6e6oco$8uh$1@was.hooked.net>
I R A Aggie <fl_aggie@thepentagon.com> wrote:
: In article <Pine.SOL.3.96.980310094407.25647A-100000@ra.isis.unc.edu>, Jim
: Murrell <lingjen@ra.isis.unc.edu> wrote:
: + I have been trying to write a short perl script
: + that takes an IP number and essentially does
: + an "nslookup". I would prefer not using the
: + system call to do but tried gethostbyaddr
: + without too much success. Does anyone have
: + an example of some perl code that does this?
: Yes, I grabbed this off the net:
[gnarly perl4 example deleted]
: I don't understand it, I just use it...
try this shiny modern perl5 version... it's more understandable too.
:)
------------------------
#!/usr/local/bin/perl -w
use Socket;
$packed_version=gethostbyaddr('hudsucker.gamespot.com');
$ascii_version=inet_ntoa($packed_version);
------------------------
gethostbyaddr returns its result in a packed format, suitable for
handing off to various kernel TCP/IP routines. inet_ntoa translates
the packed format into a human-readable one.
-jsd
------------------------------
Date: Wed, 11 Mar 1998 15:04:56 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: Perl & Cookies: How do I delete once a person leaves my site?
Message-Id: <comdog-ya02408000R1103981504560001@news.panix.com>
Keywords: from just another new york perl hacker
In article <3506A98B.14CA@disconova.com>, webmaster@disconova.com posted:
>Chocolate wrote:
>
>> Is it possible to delete a cookie once a person leaves my domain? If so
>> how?
>
>It would propably be a good idea for you to read about cookies from
>somewhere.
>
>a) Nope, it is not possible in the traditional way(*
yes it is. the Netscape cookie FAQ even tells you how. see the
CGI Meta FAQ for details.
>b) why would you like to remove a _client-side_ cookie ?
is there another kind?
>c) if you don't state any value for the cookies lifetime, it is removed
>from the giant cookie-jar as soon as the users surfing session is over -
>so... this is the closest you get to removing them - except...
you can still remove persistent cookies. see the CGI Meta FAQ
for details.
>*) If you like to use JavaScript, you could make up a piece of code that
>overwrites the cookie with nothing as soon as the user leaves (using the
>onUnload, perhaps)
you don't even need to fool with JavaScript. see the CGI Meta FAQ
for details.
--
brian d foy <comdog@computerdog.com>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
Comprehensive Perl Archive Network (CPAN) <URL:http://www.perl.com>
------------------------------
Date: Wed, 11 Mar 1998 12:51:20 -0600
From: Holly Sommer <hsommer@micro.ti.com>
Subject: Re: PID of process launched in unix system?
Message-Id: <3506DD28.CA74274A@micro.ti.com>
A *really* quick-n-dirty would be something like:
open( PS, "| ps -ef" ); # or use whatever switches you
# have available to you for ps
while(<PS>) {
if (/$processname/) {
# adjust split as necessary for your ps results
($uid, $pid, $otherstuff) = split( / /, $_, 3);
@commands = ("kill", "-9", "$pid");
system(@commands);
}
}
close(PS);
Greater minds will undoubtedly have better solutions. This one has
no error-checking either (on the open() or system()).
-Holly
------------------------------
Date: 11 Mar 1998 13:59:23 -0500
From: Jonathan Feinberg <jdf@pobox.com>
Subject: Re: printf / unlink / ?:
Message-Id: <1zw9t5o4.fsf@news.concentric.net>
hans-georg.rist@zkrd.de (Hans-Georg Rist) writes:
> if ( -e $file ) {
> printf "%ssuccessfully deleted.\n", unlink $file ? "" : "not ";
> }
> meaning: not deleted, the file still exists. I can't understand where
> this zero '0' comes from, because unlink expects a list and my list
> should end with $file!?
It seems to me like
unlink $file ? "" : "not ";
is parsed like
unlink ($file ? "" : "not ");
which in your case evaluates to
unlink "";
which is 0.
--
Jonathan Feinberg jdf@pobox.com Sunny Brooklyn, NY
------------------------------
Date: Wed, 11 Mar 1998 19:27:37 +0000
From: Joe Tully <joe.tully@virgin.net>
Subject: Running scripts under different user ID on UNIX
Message-Id: <3506E5A7.288FE129@virgin.net>
I've written a UNIX database program using a number of Perl
scripts.
I now want to set up the database securely. My intention was
to have the database directory owned by a specific user and then
set the sticky bit on the top level Perl script so that it runs
under that users ID.
However, on trying to do this I am getting problems relating to
data tainting. I looked at the "perlsec" part of the manual and
this suggested writing a C "wrapper" program (running under the
user ID) to call the perl. I tried this, but I get the same problem.
Help! Does anyone have any idea on how to get around this problem?
Thanks,
Joe Tully
------------------------------
Date: 11 Mar 1998 19:39:24 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: sorting [FAQ]
Message-Id: <6e6p9c$kg2@news-central.tiac.net>
In article <3506DAB3.B9413F5E@umich.edu>, john mann <jmann@umich.edu> wrote:
>I have an 2 dimensional array (I believe it's called), namely about
>100 pairs composed of a string of letters paired with a number.
>Something like
>
>$pins[0][0] = 23 and $pins[0][1] = CAT
>$pins[1][0] = 4 and $pins[1][1] = DOG
>$pins[2][0] = 57 and $pins[2][1] = BIRD
>
>
>I would like to sort this array, based on the letters entries (CAT, DOG,
>BIRD). So I would get;
>
>$pins[0][0] = 57 and $pins[0][1] = BIRD
>$pins[1][0] = 23 and $pins[1][1] = CAT
>$pins[2][0] = 4 and $pins[2][1] = DOG
>
>Any help would be greatly appreciated!
You might want to check out the FAQ answer at
http://www.perl.com/CPAN-local/doc/manual/html/pod/perlfaq4/How_do_I_sort_an_aray_by_anyth.html
because a solution like
@pins = sort {$a->[1] cmp $b->[1]} @pins;
or somesuch is next to useless unless you understand it. The supplied
manual pages for perldata, perlref, perllol (lists of lists), perldsc
(data structures cookbook) might help you out here. You may want a more
elaborate piece of code if you have duplicate strings and want a well
defined sort order.
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@colltech.com | Collective Technologies (work)
------------------------------
Date: 11 Mar 1998 14:09:57 -0500
From: Jonathan Feinberg <jdf@pobox.com>
Subject: Re: sorting
Message-Id: <yayhrqm2.fsf@news.concentric.net>
john mann <jmann@umich.edu> writes:
> I have an 2 dimensional array (I believe it's called), namely about
> 100 pairs composed of a string of letters paired with a number.
> Something like
>
> $pins[0][0] = 23 and $pins[0][1] = CAT
> $pins[1][0] = 4 and $pins[1][1] = DOG
> $pins[2][0] = 57 and $pins[2][1] = BIRD
In my opinion, you're using the wrong data structure. You really
ought to be using a hash.
%pins = ( CAT => 23,
DOG => 4,
BIRD => 57,
);
foreach $animal (sort keys %pins) {
print "There are $pins{$animal} $animal thingies here.\n";
}
# add a CAT
$pins{CAT}++;
Please see _Learning Perl_, and perldata.
> current cat count; 3 (1 renegade, 1 in the basement, 1 psychopussy)
Umm...
--
Jonathan Feinberg jdf@pobox.com Sunny Brooklyn, NY
------------------------------
Date: Wed, 11 Mar 1998 14:27:49 -0600
From: Jeff Stewart <object01@cc.gatech.edu>
Subject: Spitting out MIME types
Message-Id: <3506F3C5.DD5@cc.gatech.edu>
Since I can't find a newsgroup dedicated to CGI programming (and if you
feel like declaring where this post belongs, feel free)...
I'm writing a script in Perl that allows users to both upload and
download from a server. It's a modified version of another script that
spits out x-unknown as the mime type for any file the user tries to
download. How would I modify the code to have Perl let the -server-
handle the MIME declaration?
--
Jeff S.
------------------------------
Date: 11 Mar 1998 12:46:40 -0700
From: mfuhr@dimensional.com (Michael Fuhr)
Subject: Re: splice -- useful uses?
Message-Id: <6e6pn0$2ee@flatland.dimensional.com>
mike@stok.co.uk (Mike Stok) writes:
> A couple of uses might be:
>
> If you're consuming multiple elements from an array at once e.g.
>
> while (@list > 3) {
> my ($one, $two, $three) = splice @list, 0, 3;
>
> ...
> }
Or if you can handle multiple elements at a time, but no more than
$n elements on each pass:
while (@a = splice(@list, 0, $n)) {
...
}
--
Michael Fuhr
http://www.dimensional.com/~mfuhr/
------------------------------
Date: Wed, 11 Mar 1998 18:58:27 GMT
From: Carlos Reed <creed@osd.ulaval.ca>
Subject: sytem grep what does it returns
Message-Id: <Pine.SOL.3.91.980311140039.1391B-100000@vert>
I'm tryng to do a program that
a) finds all files with an extantion "*.pl"
b) search for a string "date" into each file
c) and finaly it sends the output to a file
I dont't know why but some times the grep system call
returns 256 and some times returns 0 if it didnt found
the string that I'm lookin for.
So my code doesn't works. Can any body give me a hand
with this ?
#!/opt/gnu/bin/perl
$out = "/tmp/coco";
$out2 = "/tmp/coco2";
$findstr = "date";
$rep = "./somerep";
system "/usr/bin/find $rep -name \"*.pl\" > $out";
open (IN, $out) || die "cannot open file $out";
open (OUT, ">$out2")|| die "cannot open file $out2";
while (<IN>) {
$content = system "/bin/grep $findstr $_ > /dev/null
2>&1";
if ($content == 0){
print OUT $_;}
}
close (IN);
close (OUT);
thanks in advance
Carlos Reed from beautiful and lovely Quebnec
------------------------------
Date: 11 Mar 1998 14:58:10 -0500
From: charlot@CAM.ORG (Richard Bellavance)
Subject: Re: sytem grep what does it returns
Message-Id: <6e6qci$s6n@stratus.CAM.ORG>
In article <Pine.SOL.3.91.980311140039.1391B-100000@vert>,
Carlos Reed <creed@osd.ulaval.ca> wrote:
>
>I dont't know why but some times the grep system call
>returns 256 and some times returns 0 if it didnt found
>the string that I'm lookin for.
>
I don't know why either. But did you know that Perl has a built-in
"grep" function ? Try using something like this:
print OUT "$_\n" if(grep { /$findstr/ } <IN>);
But why re-invent the wheel (unless its a school assignement :-),
just use this from the shell:
grep -l date `find ./somerep -name \*\.pl -print` > /tmp/coco2
Richard.
--
Richard Bellavance -- charlot@cam.org -- http://www.cam.org/~charlot/
"All along this path I tread / My heart betrays my weary head
With nothing but my love to save / From the cradle to the grave"
(Eric Clapton, "From the cradle")
------------------------------
Date: 11 Mar 1998 20:18:31 GMT
From: psiberjack@aol.com (Psiberjack)
Subject: What command Calls a prog on the web?
Message-Id: <19980311201800.PAA28922@ladder03.news.aol.com>
This is probably a very basic question.
I want to know how to write a standard Perl program that will call a
program on the web i(e cgi script)and store the results in a text file?
Also is it possible to store results in standard text format and not HTML?
Thanks
Rich
------------------------------
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 2076
**************************************