[10251] in Perl-Users-Digest
Perl-Users Digest, Issue: 3844 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Sep 28 17:17:20 1998
Date: Mon, 28 Sep 98 14:00:20 -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 Mon, 28 Sep 1998 Volume: 8 Number: 3844
Today's topics:
"select $variable" then print to it? <95ncp@eng.cam.ac.uk>
Re: an observation on why python will fail <eashton@bbnplanet.com>
Re: Free Shopping Cart Script (Abigail)
Re: How to obtain my server IP number ?? (Earl Hood)
Re: How to obtain my server IP number ?? droby@copyright.com
Re: Input Separator Matching (John Moreno)
Re: LWP on NT fails to fetch more than 4000 URLs. (Fergus McMenemie)
Re: mod_perl woes (Peter Rowell)
Re: Need help attaching to network resources. (Jeffrey R. Drumm)
Re: Perl and viruses <gellyfish@btinternet.com>
Re: Perl and viruses <tchrist@mox.perl.com>
Please take a look at my site <krisb@users.qual.net>
Re: Please take a look at my site (brian d foy)
Problem solved (was Re: Perl not terminating) <michel.prevost@cactuscom.ca_REMOVE_TO_MAIL>
Re: script: scriptMangle! <eashton@bbnplanet.com>
Scrolling text box? <benderle@mindspring.com>
Re: Search engine <gellyfish@btinternet.com>
Shell Command (again) sblenkhorn@my-dejanews.com
Re: Shell Command (again) (Clinton Pierce)
Unix & Perl Newbie Questions <dan.bialek@mindspring.com>
Re: Unix & Perl Newbie Questions (Stephen Booth)
Re: Where can I find a member() function? <zenin@bawdycaste.org>
Re: Where can I find a member() function? (Larry Rosler)
Re: Where can I find a member() function? (Matt Knecht)
Re: Where can I find a member() function? (Larry Rosler)
Re: Where can I find a member() function? (Craig Berry)
Re: Where can I find a member() function? <tchrist@mox.perl.com>
Re: Where can I find a member() function? (Michael Fuhr)
Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Mon, 28 Sep 1998 21:04:30 +0100
From: Nigel Parker <95ncp@eng.cam.ac.uk>
Subject: "select $variable" then print to it?
Message-Id: <Pine.HPP.3.96L.980928205552.18068A-100000@club.eng.cam.ac.uk>
Does anyone know how I can select a variable and print to it? Similar to
how you would "select STDOUT" or "select MAIL" then print to those.
I want to build up a big "$variable" then send it to my uucoding routine,
and then "print MAIL $uu_coded_variable".
I've taught myself perl in the last few weeks, so there may be an easy
solution which I've not come across! There's a lot to be printed so
something like $message = $message."Some more text.\n"; isn't really a
a very nice solution.
Any help appreciated.
Thanks.
Nigel
--
Girton College, Cambridge, England, CB3 0JG. Tel: 0411 384803
http://welcome.to/nigels nigel.parker@iee.org
------------------------------
Date: Mon, 28 Sep 1998 20:15:20 GMT
From: "Elaine -HappyFunBall- Ashton" <eashton@bbnplanet.com>
Subject: Re: an observation on why python will fail
Message-Id: <s7SP1.18$94.319885@burlma1-snr1.gtei.net>
Andrew M. Kuchling wrote in message
<13839.43130.535708.41804@amarok.cnri.reston.va.us>...
> In fact, some people have complained that comp.lang.python has
>*too many* threads about language design, and not enough threads that
>newbies can follow. (That's something new; a newsgroup drowning in
>threads that are too advanced...) Diversity of contribution is *not*
>something that's lacking in the Python community.
Cool. I never said that there wasn't, but that is certainly a factor in both
languages development tree and why they have both evolved.
> More like historical reasons, I'd expect, particularly
>pointing to Perl's early association with CGI scripts, which is still
>the primary application bringing new users to Perl. But events move
>on, and new fields such as Java bring new opportunities for things
>such as JPython.
This is true. Now, answer that question as to why Perl was early associated
with CGI and why it still is. It's not like anyone is forcing people to use
Perl.
> Coming dangerously close to invoking Godwin's law there...
Indeed.
e.
------------------------------
Date: 28 Sep 1998 20:53:00 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Free Shopping Cart Script
Message-Id: <6uosvc$3d0$1@client3.news.psi.net>
Richie Carey (nospam@dial411.com) wrote on MDCCCLIV September MCMXCIII in
<URL:news:6uo5sd$a0j$1@strato.ultra.net>:
++
++ I've just posted a FREE perl shopping cart script to my site. It is based on
++ Selena Sol's 'Web Store' but I've enhanced it to use cookies, and I've
IYM: "degraded it to use cookies".
HTH. HAND.
Abigail
--
sub _'_{$_'_=~s/$a/$_/}map{$$_=$Z++}Y,a..z,A..X;*{($_::_=sprintf+q=%X==>"$A$Y".
"$b$r$T$u")=~s~0~O~g;map+_::_,U=>T=>L=>$Z;$_::_}=*_;sub _{print+/.*::(.*)/s}
*_'_=*{chr($b*$e)};*__=*{chr(1<<$e)};
_::_(r(e(k(c(a(H(__(l(r(e(P(__(r(e(h(t(o(n(a(__(t(us(J())))))))))))))))))))))))
------------------------------
Date: 28 Sep 1998 19:12:10 GMT
From: ehood@geneva.acs.uci.edu (Earl Hood)
Subject: Re: How to obtain my server IP number ??
Message-Id: <6uon2a$9c9@news.service.uci.edu>
In article <6uofc3$m2r$1@nnrp1.dejanews.com>,
<dragnovich@my-dejanews.com> wrote:
>I want to my perl program, obtain the IP numer from the machine that it is
>ruuning, but how can I do this ???? Ie
How about:
require POSIX;
my($name, $aliases, $addrtype, $length, @addrs) =
gethostbyname((POSIX::uname())[1]);
my(@ip) = map { join(".", (unpack('C4', $_))) } @addrs;
@ip will contain all addresses for the local machine in dotted-quad
notation.
--ewh
--
Earl Hood | University of California: Irvine
ehood@medusa.acs.uci.edu | Electronic Loiterer
http://www.oac.uci.edu/indiv/ehood/ | Dabbler of SGML/WWW/Perl/MIME
------------------------------
Date: Mon, 28 Sep 1998 19:49:47 GMT
From: droby@copyright.com
Subject: Re: How to obtain my server IP number ??
Message-Id: <6uop8q$19j$1@nnrp1.dejanews.com>
In article <6uofc3$m2r$1@nnrp1.dejanews.com>,
dragnovich@my-dejanews.com wrote:
> Hello folks heres a good question! (I think)
So have many other people thought. That's why we call it a FAQ.
>
> I want to my perl program, obtain the IP numer from the machine that it is
> ruuning, but how can I do this ???? Ie
>
The answer you seek is in perlfaq9.
--
Don Roby
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum
------------------------------
Date: Mon, 28 Sep 1998 16:19:16 -0500
From: phenix@interpath.com (John Moreno)
Subject: Re: Input Separator Matching
Message-Id: <1dg2plj.8bicvl1e7zxzeN@roxboro0-031.dyn.interpath.net>
Matt Knecht <hex@voicenet.com> wrote:
> Eric Sheng <shenge@ece.ucdavis.edu> wrote:
> > I have a question on the input separator $/. Instead of trying to
> >matching the word "ERROR:", I want to match only if it is at the begining
> >of line: /^ERROR:/. But I don't know how to set the $/ variable to
> >indicate match only "ERROR:" that start at the begining of line.
>
> Just tell it to match "\nERROR:". This will fail if ERROR begins the
> data you're looking at, though. You'd have to implement something
> special to catch that.
But since you probably want to delete that from the record you can
always use:
s/^\n{0,1}ERROR://mg;
--
John Moreno
------------------------------
Date: Mon, 28 Sep 1998 21:35:53 +0000
From: fergus@twig.demon.co.uk (Fergus McMenemie)
Subject: Re: LWP on NT fails to fetch more than 4000 URLs.
Message-Id: <1dg3579.cf4y231ymp9raN@twig.demon.co.uk>
Fergus McMenemie <fergus@twig.demon.co.uk> wrote:
> hello
>
> We are using perl LWP on NT4 to download thousands of pages
> from a local web site. (actually its a CGI being called with
> different parameters:-)
>
> However we regularly see that the script fails to fetch any
> more than about 3968 pages. The $ua->request call fails with
> res->content of "Could not connect to xxxx:80". I suspect
> the perl script since to solve the problem I simply ^c the
> script and restart it, whereupon it fetches the next 3968
> pages.
>
> I tried adding a pause of 30min, within my script, after 3000
> pages to let NT/Netscape/the machine recover. This had no
> effect.
>
> perl version is 5.004_2 for NT with LWP included.
> WEB server is netscape fasttrack 2
> Machine is running NT4 with service pack 3
>
> Any ideas or suggestions.
Further to this article. I have copied the script to UNIX and had
better luck there. The unix version ran fine fethcing over 68000
page, but there appears to be some kind of limit on NT.
--
======================================================================
Fergus McMenemie Email: fergus@twig.demon.co.uk
Technical Basis
======================================================================
------------------------------
Date: 28 Sep 1998 12:24:55 -0700
From: thirdeye@sonic.net (Peter Rowell)
Subject: Re: mod_perl woes
Message-Id: <6uonq7$5hm@bolt.sonic.net>
In article <EzsGnC.5t3@csc.liv.ac.uk>, I.J. Garlick <ijg@csc.liv.ac.uk> wrote:
>In article <comdog-ya02408000R2309981646020001@news.panix.com>,
>> mod_perl involves persistent processes, so if one doesn't clean up
> ^^^^^^^^
>just exactly what does this mean in real terms?
>
>Do we physically have to undef every global variable, all variables? will
>perl no longer do garbage collecting for us?
Well, Yes and No. Perl will continue doing what it has been doing.
*You* have to become more aware of the lifetimes of your variables and
your dependency on "assumed" values and states.
In general, globals are your problem. Many programs detect that something
is being done for the first time because a global is either undefined or
has some sort of first-time-through value. This value gets munched
in various ways during the handling of the transaction. When run as
a normal CGI script, this global will get reset to the "correct"
initial value for the simple reason that the whole process gets
thrown away after each transaction, thereby requiring that the
script is compiled anew each and every time.
When run using mod_perl, your script does not exit, is not
recompiled, is not reset to any magical "just been born" state
and therefore *you* need to "clean up" the state yourself.
Globals come in several flavors: yours, perl's and "embodied state".
I assume you know where and what your globals are and can simply
create a routine call initialize_globals to be called each time
you start a new transaction. I find it easier to do this at the
start of a transaction (rather than at the end) because of the
way my brain is wired. When creating this routine, it may dawn
on you that "Damn! I have a *lot* of globals!", which is a good
learning experience in and of itself.
This routine also would be a good place to reset any of perl's globals
that you might have messed with. For instance, $/ may have been set to
a different input record separator half-way through the script, but you
expected it to be the default value for the first half. So remember to
set these to their expected initial state.
Finally "embodied state". This can be harder to spot than you might
think. Some of it is state created by the compiler and some of it is
hidden state in some module you may be using. The latter is probably
more of a bug (theirs or yours), but you have to be aware that it could
happen or you will go insane trying to figure out what is wrong.
You may also need to be aware of file-system-related objects:
open files (you need to close them when done - it's just good hygiene),
files that use the process ID ($$) in some magical (and assumed to
be constantly changing) way, etc.
Here is an example of compiler-created state. I have a search engine
that uses /$foo/o to speed things up (remember the 'o' flag promises
the compiler that the pattern won't change after the first time the
operator is used). HOWEVER the value of $foo is dependent on the current
transaction and so this will only work correctly for the first query.
What I do is wrap this code in an eval so that it gets recompiled each
time with a new value. This looks like:
eval <<GROK;
foreach $line (@lines) {
# do stuff
next unless $line =~ /$foo/o;
# do more stuff
}
GROK
NOTE: don't put the eval inside the loop or it will recompile on
each iteration, which is inefficient and slow.
>
>I think I understand what this means and I have read it in several documents
>some of which you mention below but I haven't found anywhere it says exactly
>what to do and what not to do. For instance if I was to create and object say
>and return a blessed reference do I physically ned to destroy it?
Only if you keep it in a global (or something hanging off of a global)
that has no further use. For example, say you did the following:
$global_hash_of_queries{$query_string} = <some big object>;
Well, if after the current query you will never look at this element
again, then by all means explicitly delete it. Other wise it will hang
around until the whole process exits - which situation might be forced
by running out of memory by hanging on to undeeded stuff! :-)
>or can I
>leave it (don't know the term here, alive?) in existance and reasign values
>to it next time I use an httpd that has already initialised it?
Yes. To my knowledge, Perl does not attempt to return memory to the OS
(and there aren't any generally-used OSes to take advantage if it tried).
So it doen't matter when it is freed, because it just goes back into Perl's
internal free list.
>Ian J. Garlick
><ijg@csc.liv.ac.uk>
Cheers!
Peter Rowell
peter@thirdeye.com
------------------------------
Date: Mon, 28 Sep 1998 19:08:31 GMT
From: drummj@mail.mmc.org (Jeffrey R. Drumm)
Subject: Re: Need help attaching to network resources.
Message-Id: <360fddb1.371080655@news.mmc.org>
[ posted to comp.lang.perl.misc and a courtesy copy was mailed to the cited
author ]
On Sun, 27 Sep 1998 17:33:56 -0700, "Michael Copeland" <mcope@earthlink.net>
wrote:
>I have been trying to attach to network resources using the
>Win32::Netresoucre module. but I don't seem to have the statement correct.
>Could some please seem me an example of how the addconnection expression is
>suppose to be used.
>
>Your help would be greatly appreciated.
>
>Michael
>
There are a number of examples @ www.dejanews.com . . . most of 'em from me. If
you'd stopped there first, you'd have had your answer by now. ;-)
--
Jeffrey R. Drumm, Systems Integration Specialist
Maine Medical Center - Medical Information Systems Group
drummj@mail.mmc.org
"Broken? Hell no! Uniquely implemented!" - me
------------------------------
Date: 28 Sep 1998 19:12:27 -0000
From: Jonathan Stowe <gellyfish@btinternet.com>
Subject: Re: Perl and viruses
Message-Id: <6uon2r$df$1@gellyfish.btinternet.com>
On Mon, 28 Sep 1998 04:00:03 +0300 8734.g23 <8734.g23@g23.relcom.ru> wrote:
> I would like to discuss a problem detection and destruction of viruses by
> Perl. Who knows similar algorithm?.
He,He.
I suppose you *could* do it given the signature files from some established
anti-virus software (given that such files were freely available or even
documented) - but if ever I heard of reinventing the wheel.
Having said that though I would be interested and delighted to hear if
anyone had succeeded in this direction.
There are several groups that discuss computer viruses have you looked at
them? They might be able to offer the kind of help on identifying virii that
probably isnt available here.
> Regards?
No problem ?
> Nicolai Yanishevsky
/J\
--
Jonathan Stowe <jns@btinternet.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
------------------------------
Date: 28 Sep 1998 19:58:03 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Perl and viruses
Message-Id: <6uopob$h0f$2@csnews.cs.colorado.edu>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc, Jonathan Stowe <gellyfish@btinternet.com> writes:
:identifying virii
Pardon me, but just which declension would that be? For noun plurals,
I know several "-us" rules. I know of "-us to -uses", "-us to -i",
"-us to -us", "-us" to "-ora", and the "-us to -era" rules, but to date,
I know of no "-us to -ii" rule in Latin, Greek, or anywhere else you
might allege to derive "virus" from. Could you please explain this
"-us to -ii" rule that you are alleging here? It follows from nothing
I have ever read.
--tom
--
"I discount everything Djikstra has to say because he doesn't actually
run his programs" --Rob Pike, On Djikstra's belief that bugs in your
program are a moral failure to prove your program mathematically correct.
------------------------------
Date: Mon, 28 Sep 1998 20:14:47 GMT
From: Kris Bernardic <krisb@users.qual.net>
Subject: Please take a look at my site
Message-Id: <3610189C.86E6F792@users.qual.net>
I would be most appreciative if some of you out there could take a look
at a rough (and I mean rough) draft of my site. Check it out at:
http://www.fit2print.com/high/index.html
Keep in mind this is a very rough draft (alot of the links don't work
yet). What I need to know is if this Java/CGI shopping cart system will
work. Is the download time unrealistic? I'm planning on having 3 site
versions: a fast page (with minimal graphics) and medium page (with
black & white graphics) and a slow page (with full color graphics). So
if this page(full color) has a tolerable download time then I know the
others will work.
One last thing, do you think a Java site is worth persuing now or would
it be better to wait until the technology (ie bandwidth) can handle it.
Thanks in advance.
Kris
--
fit2print.com - Your Digital Newsstand
Order magazines "on demand" @ http://www.fit2print.com
------------------------------
Date: Mon, 28 Sep 1998 16:40:15 -0400
From: comdog@computerdog.com (brian d foy)
Subject: Re: Please take a look at my site
Message-Id: <comdog-ya02408000R2809981640150001@news.panix.com>
Keywords: from just another new york perl hacker
In article <3610189C.86E6F792@users.qual.net>, Kris Bernardic <krisb@users.qual.net> posted:
>I would be most appreciative if some of you out there could take a look
>at a rough (and I mean rough) draft of my site. Check it out at:
>Keep in mind this is a very rough draft (alot of the links don't work
>yet). What I need to know is if this Java/CGI shopping cart system will
>work.
perhaps you can write an LWP robot to test this for you. other than
that, what does this have to do with Perl? perhaps you wanted one of
the groups that discusses web things.
--
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>
Perl Mongers needs volunteers! <URL:http://www.pm.org/to-do.html>
------------------------------
Date: Mon, 28 Sep 1998 15:49:18 -0400
From: Michel Prevost <michel.prevost@cactuscom.ca_REMOVE_TO_MAIL>
To: Ilya Zakharevich <ilya@math.ohio-state.edu>
Subject: Problem solved (was Re: Perl not terminating)
Message-Id: <360FE83E.1677C2EF@cactuscom.ca_REMOVE_TO_MAIL>
Thanks, but i was able to figure out. It looks like perl spans a bunch of children.
For example, when you call cwd(), it forks and exec pwd.
I figured this out by executing the script using truss (thanks to Jonathan Stowe for
the suggestion).
the script was opening 2 differnet connections to an Oracle database. For each of the
connection, a process was spawned by Perl. When the first dies, Perl correctly wait()s
for it, but it does not wait for the second one. It is repetively sent the SIGCLD
signal, like in an infinite loop. And every time, it calls sigaction. Here is the
trace:
15299: Received signal #18, SIGCLD [caught]
15299: sigaction(SIGCLD, 0xEFFFC758, 0xEFFFC7D8) = 0
15299: new: hand = 0xEF5B8D50 mask = 0 0 0 0 flags = 0x000C
15299: old: hand = 0xEF5B8D50 mask = 0 0 0 0 flags = 0x000C
15299: setcontext(0xEFFFC9A8)
This is output indefinetly until I kill the process. Very strange, don't really what
is going here. The problem is fixed though.
Tx to everyone.
MIchel
Ilya Zakharevich wrote:
> [A complimentary Cc of this posting was sent to Michel Prevost
> <michel.prevost@cactuscom.ca_REMOVE_TO_MAIL>],
> who wrote in article <360F8458.29404A6E@cactuscom.ca_REMOVE_TO_MAIL>:
> > I know that the script is in exit() because i put the folllowing:
> >
> > print "about to exit\n";
> > exit(0);
> >
> > I did that to make sure that the script was exiting (or trying to or
> > whatever). In
> > fact, this began to happen to many scripts that haven't been touched since eons.
> > It may be because of some module(s) we updated. Maybe there is an
> > infinite loop in
> > some DESTROY function.
> >
> > I will try truss. It may help
>
> If this is a Perl loop, you will need Perl debugger. Do the recomended
>
> env "PERLDB_OPTS=N f=2" perl -d your_script args
>
> (change f=2 to f=63 if it suits you, and/or add 'A'). Use 'L=outfile'
> to get the messages to a file (otherwise they go to /dev/tty, thus are
> not redirectable).
>
> In fact, you may want to omit f=2, and do
>
> $DB::trace = 1;
>
> before exiting. (Lemme look... Aha, it is simply $DB::frame = 63 to
> set f=63 in runtime.)
>
> Ilya
------------------------------
Date: Mon, 28 Sep 1998 20:04:40 GMT
From: "Elaine -HappyFunBall- Ashton" <eashton@bbnplanet.com>
Subject: Re: script: scriptMangle!
Message-Id: <sZRP1.17$94.316318@burlma1-snr1.gtei.net>
>hmm, lets see. open up websters, find obfuscate. ahh here we are:
>> obfuscate 2. to make *obscure* or unclear
Hmmm. I stand corrected. Don't have my OED nearby. Well, take my point,
obfuscated perl is not sup3r s33kr3t c0dz. :)
e.
------------------------------
Date: Mon, 28 Sep 1998 14:33:59 -0400
From: Brian Enderle <benderle@mindspring.com>
Subject: Scrolling text box?
Message-Id: <360FD697.E36A32EA@mindspring.com>
I would like to put a scrolling text box in one frame of my page. I
have seen this done elsewhere only I cannot remember where. I would
like it to read a list from a text file and just keep scrolling through
that list while the user is surfing through other pages. I assume it
would have to be either cgi or java.
My thanks in advance
brian enderle
------------------------------
Date: 28 Sep 1998 18:49:41 -0000
From: Jonathan Stowe <gellyfish@btinternet.com>
Subject: Re: Search engine
Message-Id: <6uolo5$d9$1@gellyfish.btinternet.com>
On Mon, 28 Sep 1998 07:06:16 -0500 Greg Hassan <greg@hassan.com> wrote:
> Jonathan Stowe wrote:
>>
>> > Does anyone know of a perl/cgi serach engine available. Not a search for
>> > your site but for the net as a whole. Similar to yahoo, excite, lycos etc.,
>> > etc., etc.
>>
>>
> Hmm:
> Host your own specialized internet search engine:
> http://www.hassan.com/site_searcher/
Hey, Stealth CC, Mis-attribution *and* self-promotion: not a bad start.
/J\
--
Jonathan Stowe <jns@btinternet.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
------------------------------
Date: Mon, 28 Sep 1998 18:54:08 GMT
From: sblenkhorn@my-dejanews.com
Subject: Shell Command (again)
Message-Id: <6uom0g$tad$1@nnrp1.dejanews.com>
This is the code I have now tried and it still does not work. However if I
hard code the whole statement (ie. don't reference any variables) it works.
So obviously it does not like the fact I am trying to substitute in variable
values. Do shell commands not let you use variables in the statements?? Or
is there a way to concatenate the statement to include variables? See my
code below:
use Win32::Process;
Win32::Process::Create($Process,
"d:\\www\\rp\\cgi-bin\\pkzip25.exe",
"d:\\www\\rp\\cgi-bin\\pkzip -add -sfx
d:\\www\\rp\\$dir_type\\$dir_name\\$file_name
d:\\www\\rp\\$dir_type\\$dir_name\\*.*",
0,
DETACHED_PROCESS,
".") || die "Create: $!";
Thanks in advance,
Sean Blenkhorn
PERC Intranet Development Team, CIBC
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum
------------------------------
Date: 28 Sep 1998 19:31:03 GMT
From: cpierce1@cp500.fsic.ford.com (Clinton Pierce)
To: sblenkhorn@my-dejanews.com
Subject: Re: Shell Command (again)
Message-Id: <6uoo5n$b2l3@eccws1.dearborn.ford.com>
In article <6uom0g$tad$1@nnrp1.dejanews.com>,
sblenkhorn@my-dejanews.com writes:
>This is the code I have now tried and it still does not work. However if I
>hard code the whole statement (ie. don't reference any variables) it works.
>So obviously it does not like the fact I am trying to substitute in variable
>values. Do shell commands not let you use variables in the statements?? Or
>is there a way to concatenate the statement to include variables? See my
>code below:
Yes, you can substitute variables just fine. Perl does that (since it's in
double-quotes), not the shell.
>use Win32::Process;
>
>Win32::Process::Create($Process,
> "d:\\www\\rp\\cgi-bin\\pkzip25.exe",
> "d:\\www\\rp\\cgi-bin\\pkzip -add -sfx
> d:\\www\\rp\\$dir_type\\$dir_name\\$file_name
> d:\\www\\rp\\$dir_type\\$dir_name\\*.*",
> 0,
> DETACHED_PROCESS,
> ".") || die "Create: $!";
I've only done this a few times, so here's a couple of suggestions:
1. Search Dejanews. There are LOTS of examples floating around about
how to do this. (Your mail account is on DejaNews. :-)
2. Is it pkzip25.exe or pkzip.exe? Pick one or the other. You can't
run one, and specify another. At least it doesn't make sense to.
3. Did you really want newline characters embedded in your command name?
Perl isn't picky about newlines, and is happy to continue your
string literal on the next line. But it will include the new line
character too (after the -sfx and $file_name). Your command.exe
might not be happy with them, though.
4. The glob (*.*) might give you trouble. Debug it by pkzipping ONE
file. Then add the glob in when you get that working.
--
+------------------------------------------------------------------------+
| Clinton A. Pierce | "If you rush a Miracle Man, | http://www. |
| cpierce1@ford.com | you get rotten miracles" | dcicorp.com/ |
| fubar@ameritech.net |--Miracle Max, The Princess Bride| ~clintp |
+------------------------------------------------------------------------+
GCSd-s+:+a-C++UALIS++++P+++L++E---t++X+b+++DI++++G++e+>++h----r+++y+++>y*
------------------------------
Date: Mon, 28 Sep 1998 12:53:43 -0700
From: Dan Bialek <dan.bialek@mindspring.com>
Subject: Unix & Perl Newbie Questions
Message-Id: <360FE947.FE39C211@mindspring.com>
To whom it may concern,
Hello. I am a Windows user who is interested in learning about the Unix
OS and Perl programming.
My two basic questions are(in several parts each):
1. How do I get a copy Unix and what version should I use (e.g. Linux)
And once I get this software, can I run it on a PC that also runs
Windows 98, and if so
how?
2. How and where do I write Perl programs and test them. Can I write
them in Windows and
test them with some sort of compiler, or do I have to write them on
a Unix system?
I apologize for the great deal of ignorance on my part for not knowing
this type of information.
Any clear, concise answers would be very helpful.
I do not mind being referred to any of the numerous FAQ's found on the
Net. However,
more personal, plain-English answers from a human being would be much
greatly appreciated.
If you have any input about these topics, please email me.
Thank you,
Dan Bialek
dan.bialek@mindspring.com
P.S. Feel free to flame me if these questions are too basic and
infantile for your newsgroup;
I really didn't know where else to find help. :-)
------------------------------
Date: Mon, 28 Sep 1998 20:50:09 GMT
From: stephenbooth@bigfoot.com (Stephen Booth)
Subject: Re: Unix & Perl Newbie Questions
Message-Id: <3614f499.206280682@news.demon.co.uk>
On Mon, 28 Sep 1998 12:53:43 -0700, Dan Bialek
<dan.bialek@mindspring.com> wrote:
>To whom it may concern,
>
>Hello. I am a Windows user who is interested in learning about the Unix
>OS and Perl programming.
>
>My two basic questions are(in several parts each):
>
>1. How do I get a copy Unix and what version should I use (e.g. Linux)
> And once I get this software, can I run it on a PC that also runs
>Windows 98, and if so
> how?
>
Linux can be downloaded free from loads of places, you can buy a
couple of commercial versions (try your usual software supplier).
It's possible but not advisable to run Linux dual booting with
Windows 98. I only know one person who has done it and he used
System commander to do the dual boot. At a minimum Linux needs a
completly separate partician and someway of selecting between it
and the other OS at boot up. IIRC the Windows 98 boot menu
doesn't work with Linux.
>2. How and where do I write Perl programs and test them. Can I write
>them in Windows and
> test them with some sort of compiler, or do I have to write them on
>a Unix system?
>
You can download loads of perl related stuff including a Perl
interpreter for windows from http://www.perl.com and
http://www.perl.org as well as a load of other sites.
>I apologize for the great deal of ignorance on my part for not knowing
>this type of information.
>Any clear, concise answers would be very helpful.
>
We all started somewhere.
Stephen
--
Stephen Booth #include<std_disclaimer.h>
Technical analyst
Achieving BOFH status
If my employers shared my opinions they'd pay me more.
------------------------------
Date: 28 Sep 1998 19:04:36 GMT
From: Zenin <zenin@bawdycaste.org>
Subject: Re: Where can I find a member() function?
Message-Id: <907009401.526792@thrush.omix.com>
[posted & mailed]
Brian Kendig <fox@enchanter.net> wrote:
: I want a subroutine which takes a scalar and a list as input, and
: returns true if a copy of the scalar exists in the list.
:
: This seems so basic and fundamental that I'm surprised not to find it
: mentioned in the camel book, but I can't even find any modules on CPAN
: which implement it!
perldoc perlfaq4
"How can I tell whether an array contains a certain element?"
: Are Perl hackers not supposed to think of lists this way?
No. We normally smoke hash instead. :-)
: I would write a member() function myself, except I'm having trouble
: figuring out how to pass an array by reference rather than by value.
member ($scalar, \@array_by_ref);
Inside member(), you'll have @$array_ref, or if you really
want to be explicit, ${ @array_ref }, but that's ugly. :-)
--
-Zenin (zenin@archive.rhps.org) From The Blue Camel we learn:
BSD: A psychoactive drug, popular in the 80s, probably developed at UC
Berkeley or thereabouts. Similar in many ways to the prescription-only
medication called "System V", but infinitely more useful. (Or, at least,
more fun.) The full chemical name is "Berkeley Standard Distribution".
------------------------------
Date: Mon, 28 Sep 1998 12:12:17 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Where can I find a member() function?
Message-Id: <MPG.10797f6d1aa9be859897c8@nntp.hpl.hp.com>
[Posted to comp.lang.perl.misc and a copy mailed.]
In article <6uolmg$jk0@flatland.dimensional.com> on Mon, 28 Sep 1998
18:49:05 GMT, Michael Fuhr <mfuhr@dimensional.com> says...
> fox-at-enchanter-net@SPAM.BLOCK (Brian Kendig) writes:
> > I want a subroutine which takes a scalar and a list as input, and
> > returns true if a copy of the scalar exists in the list.
...
> What are you trying to do that Perl's builtin "grep" doesn't handle?
> Or have I just become troll bait?
Well, it is likely that "grep" is not the best answer, as discussed in
perlfaq4: "How can I tell whether an array contains a certain element?"
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Mon, 28 Sep 1998 19:13:40 GMT
From: hex@voicenet.com (Matt Knecht)
Subject: Re: Where can I find a member() function?
Message-Id: <EdRP1.960$7Q6.6419308@news2.voicenet.com>
Brian Kendig <fox-at-enchanter-net@SPAM.BLOCK> wrote:
>I want a subroutine which takes a scalar and a list as input, and
>returns true if a copy of the scalar exists in the list.
Use either:
$found_it = grep { $scalar_to_look_for eq $_ } @array;
or
for (@array) { $found_it++, last if $scalar eq $_ }
On large arrays, the for loop can be much faster, as it doesn't have to
check any elements after it finds a match (You can't bail out of a
grep-induced loop, so grep goes through ALL elements).
>This seems so basic and fundamental that I'm surprised not to find it
>mentioned in the camel book, but I can't even find any modules on CPAN
>which implement it! Are Perl hackers not supposed to think of lists
>this way?
It is basic and fundamental. That is why Perl has hashes. This sort of
operation is *much* easier on a hash.
Unless you are using arrays for a specific reason, you would probably be
better served using a hash.
$found_it = exists $hash{$key_to_look_for};
This is by far the fastest way to get what you want.
>I would write a member() function myself, except I'm having trouble
>figuring out how to pass an array by reference rather than by value.
@array = qw / zero one two /;
pass_ref(\@array);
$arr_ref = \@array;
pass_ref($arr_ref);
sub pass_ref
{
my $array_ref = shift;
# Don't need this next line, but it can't hurt
die "Not an array ref!\n" unless ref $array_ref eq 'ARRAY';
# You can dereference many ways:
print "Array element zero by ref is:", $array_ref->[0], "\n";
print "Array element one by ref is:", $$array_ref[1], "\n";
print "Array element two by ref is:", ${$array_ref}[2], "\n";
}
--
Matt Knecht - <hex@voicenet.com>
------------------------------
Date: Mon, 28 Sep 1998 12:10:36 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Where can I find a member() function?
Message-Id: <MPG.10797f0257f3b35b9897c7@nntp.hpl.hp.com>
In article <6uokro$oqj$1@shell11.ba.best.com> on 28 Sep 1998 11:34:32 -
0700, Brian Kendig <fox-at-enchanter-net@SPAM.BLOCK> says...
> I want a subroutine which takes a scalar and a list as input, and
> returns true if a copy of the scalar exists in the list.
>
> This seems so basic and fundamental that I'm surprised not to find it
> mentioned in the camel book, but I can't even find any modules on CPAN
> which implement it! Are Perl hackers not supposed to think of lists
> this way?
>
> I would write a member() function myself, except I'm having trouble
> figuring out how to pass an array by reference rather than by value.
How good are you at wheel-reinvention?
The answer is in perlfaq4, which you can find on the same hard disk where
your perl is installed: "How can I tell whether an array contains a
certain element?"
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: 28 Sep 1998 19:46:52 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Where can I find a member() function?
Message-Id: <6uop3c$5a7$1@marina.cinenet.net>
Brian Kendig (fox-at-enchanter-net@SPAM.BLOCK) wrote:
: I want a subroutine which takes a scalar and a list as input, and
: returns true if a copy of the scalar exists in the list.
This is a FAQ. There's not built-in subroutine, but it'd be easy to write
one based on the FAQ. Note that you need to decide what kind of equality
test to use to determine if the scalar is in the list.
: This seems so basic and fundamental that I'm surprised not to find it
: mentioned in the camel book, but I can't even find any modules on CPAN
: which implement it! Are Perl hackers not supposed to think of lists
: this way?
Bingo. When you think the word 'exists', there should be a Pavlovian
hard-wired neurological connection to your finger hitting the '%' key.
Use the hash, Luke.
: I would write a member() function myself, except I'm having trouble
: figuring out how to pass an array by reference rather than by value.
my @array = qw(foo bar baz);
print member('foo', \@array) ? 'is' : 'not';
Of course, you could pass the array by value, too; the first arg is the
scalar to match, every following arg is part of the array:
sub member
{
my ($item, @list) = @_;
...
}
---------------------------------------------------------------------
| Craig Berry - cberry@cinenet.net
--*-- Home Page: http://www.cinenet.net/users/cberry/home.html
| "Ripple in still water, when there is no pebble tossed,
nor wind to blow..."
------------------------------
Date: 28 Sep 1998 19:51:59 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Where can I find a member() function?
Message-Id: <6uopcv$h0f$1@csnews.cs.colorado.edu>
In comp.lang.perl.misc, fox-at-enchanter-net@SPAM.BLOCK (Brian Kendig) writes:
:I want a subroutine which takes a scalar and a list as input, and
:returns true if a copy of the scalar exists in the list.
The bottom line SPAM<http://> is you've gone and SPAM<language.> used
the wrong data structure. SPAM<perl.> Arrays are SPAM<com/> not for
SPAM<doc> searching. Lists are not SPAM</manual> for searching. They
just SPAM</html> aren't designed SPAM</pod> for this, so SPAM</perlfaq4>
to ask this question you've SPAM<.html> already shown that you've gone
SPAM<#How_> down the wrong path. The SPAM<can_> complete answer to your
SPAM<I_tell_> question can be SPAM<whether_> found spamblocked in this
SPAM<a_list_or> very message.
--tom
--
[End of diatribe. We now return you to your regularly scheduled
programming...]
--Larry Wall in Configure from the perl distribution
------------------------------
Date: Mon, 28 Sep 1998 20:35:39 GMT
From: mfuhr@dimensional.com (Michael Fuhr)
Subject: Re: Where can I find a member() function?
Message-Id: <6uorug$n1g@flatland.dimensional.com>
lr@hpl.hp.com (Larry Rosler) writes:
> [Posted to comp.lang.perl.misc and a copy mailed.]
>
> In article <6uolmg$jk0@flatland.dimensional.com> on Mon, 28 Sep 1998
> 18:49:05 GMT, Michael Fuhr <mfuhr@dimensional.com> says...
> > fox-at-enchanter-net@SPAM.BLOCK (Brian Kendig) writes:
> > > I want a subroutine which takes a scalar and a list as input, and
> > > returns true if a copy of the scalar exists in the list.
> ...
> > What are you trying to do that Perl's builtin "grep" doesn't handle?
> > Or have I just become troll bait?
>
> Well, it is likely that "grep" is not the best answer, as discussed in
> perlfaq4: "How can I tell whether an array contains a certain element?"
Yeah, I was in a hurry and didn't think before answering that one.
My apologies to the less-experienced readers if my answer implied
that "grep" was a good solution for this problem.
--
Michael Fuhr
http://www.fuhr.net/~mfuhr/
------------------------------
Date: 12 Jul 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Special: Digest Administrivia (Last modified: 12 Mar 98)
Message-Id: <null>
Administrivia:
Special notice: in a few days, the new group comp.lang.perl.moderated
should be formed. I would rather not support two different groups, and I
know of no other plans to create a digested moderated group. This leaves
me with two options: 1) keep on with this group 2) change to the
moderated one.
If you have opinions on this, send them to
perl-users-request@ruby.oce.orst.edu.
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 3844
**************************************