[17842] in Perl-Users-Digest
Perl-Users Digest, Issue: 2 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Jan 5 18:05:53 2001
Date: Fri, 5 Jan 2001 15:05:10 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <978735910-v10-i2@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Fri, 5 Jan 2001 Volume: 10 Number: 2
Today's topics:
&sub vs. sub() style? <jbc@west.net>
Re: Directory monitoring (Cameron Laird)
Re: FAQ 7.9: How do I create a module? (Tad McClellan)
Re: FAQ 7.9: How do I create a module? <montuori@arrakisplanet.com>
Good Tutorial... alan@jorsm.com
Re: Good Tutorial... (Paul Delahunta)
How do I get 'print $the_stuff' to not print 'I see $i <xzrgpnys@yvtugubhfrovm.pbz>
I need a specific release of Perl <don@lclcan.com>
Re: I need a specific release of Perl <dan@tuatha.sidhe.org>
Re: Installing dbi dbd on linux (Honza Pazdziora)
JAPH critique <cm142@freenet.buffalo.edu>
Re: JAPH critique <elijah@workspot.net>
Just how experimental *is* Multithreading? <cliff@*MYLASTNAMEHERE*.nl>
Re: Just how experimental *is* Multithreading? <dan@tuatha.sidhe.org>
Match a reg.ex. EXCEPT inside quotes? <no@spam.com>
Re: Match a reg.ex. EXCEPT inside quotes? <iltzu@sci.invalid>
Re: Match a reg.ex. EXCEPT inside quotes? (Tad McClellan)
Net::Telnet and --More-- <neil@alaweb.com>
New to perl question about traversing directories and s cputek1@my-deja.com
Re: perl and zombies woodywit@my-deja.com
Re: perl and zombies (Martien Verbruggen)
Re: perl and zombies (Martien Verbruggen)
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 05 Jan 2001 14:49:00 -0800
From: John Callender <jbc@west.net>
Subject: &sub vs. sub() style?
Message-Id: <3A564F5C.CC64BF47@west.net>
I'm currently working on some beginning-programmer-oriented Perl
documentation. In my materials I've been invoking subroutines
with a leading ampersand (&sub), but I've been told that doing so
looks very Perl4-ish, and that I should instead invoke such
subroutines like sub(). This was presented to me as being mainly
an aesthetic/style type of issue, though I suppose there also
might be more substantive concerns behind the objection.
Now, it's true that these leading ampersands are a legacy of my
Perl4 days. But it seems to me that there might be some value, at
least for a very-early-stages learner unfamiliar with many of
Perl's built-in functions, in keeping the ampersand to
disambiguate invocations of a user-defined subroutine from
invocations of a built-in function. It may be ugly from the
perspective of a moderately experienced user, but for an absolute
beginner, a leading ampersand seems to me to be a useful symbol,
a life ring that my hypothetically
floundering-in-a-sea-of-new-concepts user could cling to, as in,
"ah! an ampersand! this must be a user-defined subroutine."
Anyway, I'm curious what people think about this. Thanks in
advance.
--
John Callender
jbc@west.net
------------------------------
Date: 5 Jan 2001 16:04:14 -0600
From: claird@starbase.neosoft.com (Cameron Laird)
Subject: Re: Directory monitoring
Message-Id: <BE01BDEF57AB7A98.794CB190CBE3A895.59C3C6D8CD4B2A7B@lp.airnews.net>
In article <934r5f$mad$1@nnrp1.deja.com>, <canderson69@my-deja.com> wrote:
>I know that a UNIX directory can be monitored via
>stat() for any modifications... but that requires
>a delay and periodically checking mtime. Is there
>some kind of blocking function that will cause a
>perl script to sleep until a directory is
>modified? Thanks.
.
.
.
No.
It's a good question. Research OSs exist which
provide this. It's not available in stock Unix,
though; you *must* poll, or some equivalent.
It's easy enough to do in Perl, if I understand
you correctly. Just sleep for a few seconds,
check for changes, and then either continue with
other processing or loop back to the sleep.
--
Cameron Laird <claird@NeoSoft.com>
Business: http://www.Phaseit.net
Personal: http://starbase.neosoft.com/~claird/home.html
------------------------------
Date: Fri, 5 Jan 2001 13:08:24 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: FAQ 7.9: How do I create a module?
Message-Id: <slrn95c3co.q9b.tadmc@magna.metronet.com>
BUCK NAKED1 <dennis100@webtv.net> wrote:
>I have always used a telnet script to install modules,
So then, you must always be installing modules on some
computer other than the one you are logged into.
That is "remotely". I though you said you wanted to install
them "locally"?
That is not the "normal" access mode.
You normally install modules on the computer that you are logged into.
>and know of no
>other way to do it.
Type the commands at the command line prompt.
>FWIW, my webhost doesn't have CPAN.pm, and I think
>you need to be root to install CPAN.pm anyway.
I guess "webhost" means "not the computer that I am logged into",
so then, yes, _you_ do need telnet or similar.
You seem to still be thinking that Perl is CGI.
Perl is not CGI.
The "normal environment" for Perl programs is the command line,
but it can work in other environments too.
I have programmed in Perl every day for over 5 years and
have never written a CGI program (except as a hobbyist).
If all you do with Perl is CGI stuff, you are missing out on
a whole other world.
>It took me months of research, after reading the perldocs and
>FAQ, and asking questions here on "how do I install a module locally",
Maybe a cause of the friction is that you keep on saying "locally"
when you mean "remotely". If you say the opposite of what you
meant, you should expect that things will not go smoothly.
You do NOT need telnet to install modules locally!
You don't!
Really!
>JAPB [ just another perl beg-inner ]
^^^ ^^^^^
^^^ ^^^^^
I particularly like that :-)
--
Tad McClellan SGML consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Fri, 5 Jan 2001 17:12:58 -0500
From: kevin montuori <montuori@arrakisplanet.com>
Subject: Re: FAQ 7.9: How do I create a module?
Message-Id: <ydyu27dd4wz.fsf@kulon.arrakisplanet.com>
>>> BUCK NAKED1 writes:
bn> The FAQs, perldocs, etc. are definitely a good resource. I use
bn> them often. My point is just that they are not the "end-all", as
bn> many people here tend to imply.
of course not. your comprehension of the FAQs, manpages,
&c. are the "end-all".
i think you might be thinking that installing modules and
installing (let's say) MS word are similiar activities. but
they're not.
modules are tools, used by programmers. as such, it's not
entirely unreasonable to expect the people installing them to
know their OS pretty well, to know something about what's
going on behind the scenes when they type 'make' and 'make
install', and to know how to troubleshoot when things go
wrong.
i think the docs do a pretty good job of explaining how it's
supposed to work, and where you might want to look if things
start to go wrong. man pages should do no more hand holding
that that.
cheers,
k.
--
kevin montuori
support independent booksellers -- http://www.booksense.com
------------------------------
Date: Fri, 05 Jan 2001 20:08:49 GMT
From: alan@jorsm.com
Subject: Good Tutorial...
Message-Id: <9359k9$4an$1@nnrp1.deja.com>
Could anybody give me some links to a good tutorial on using Perl to
pull data from and modify MS Access Databases?
Thank you much,
-Al-
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: Fri, 05 Jan 2001 21:53:12 GMT
From: mustbe@pdelahunta.cjb.com (Paul Delahunta)
Subject: Re: Good Tutorial...
Message-Id: <3a564245.12870078@news.planet.nl>
On Fri, 05 Jan 2001 20:08:49 GMT, alan@jorsm.com wrote:
>Could anybody give me some links to a good tutorial on using Perl to
>pull data from and modify MS Access Databases?
Selena Sol (http://www.extropia.com) has an extensive tutorial on Perl
for databases. I wouldn't be suprised at all if it has an answer to
your question.
Paul
------------------------------
Date: 05 Jan 2001 22:17:46 GMT
From: kevin metcalf <xzrgpnys@yvtugubhfrovm.pbz>
Subject: How do I get 'print $the_stuff' to not print 'I see $i trees'?
Message-Id: <3A5648A2.717E38DA@yvtugubhfrovm.pbz>
Here's the part of the code that matters:
*******
$option_line = "<option ";
unless ($contents{print_option} == 0) { $option_line .=
'value="$i"';}
$newlinechar=$contents{newlinechar};
if ($newlinechar eq "ret") {$newlinechar="\n";}
unless ($contents{extra} eq "") {$option_line .= " $contents{extra}"; }
$option_line .= '>$i' . "$newlinechar";
$countfrom=$contents{countfrom};
$countto=$contents{countto};
$countto++;
for ($i=$countfrom; $i<$countto; $i++){
print /$option_line/e;
}
*******
I want the user to be able to include $i in the $contents{extra} field,
and have it it print correctly in the for loop. Right now, it prints:
<option value="$i" [FMP-if:Q_Display_Order.eq.$i]selected[/FMP-if]>$i
instead of:
<option value="45" [FMP-if:Q_Display_Order.eq.45]selected[/FMP-if]>45
Anyone know how to get this to expand correctly? I couldn't find
anything in the camel book (probably because I didn't know what to look
for. Any help?
Thanks!
--
Kevin Metcalf
(Carbon Ocelot)
email: xzrgpnys@yvtugubhfrovm.pbz
Huh? http://www.flactem.com/utils/rot13.html
------------------------------
Date: Fri, 05 Jan 2001 15:14:49 -0500
From: Don <don@lclcan.com>
Subject: I need a specific release of Perl
Message-Id: <3A562B38.DE98EBFE@lclcan.com>
Hi,
I'm using Perl 5.60 and I've discovered a bug that makes my module
within my script unusable. I was told by the creator of the module that
the bug was fixed in version 5.61
However, when I go to the download sites, all I see is 5.60 or 5.70
Where can I get 5.61?
Thanks,
Don
------------------------------
Date: Fri, 05 Jan 2001 20:25:37 GMT
From: Dan Sugalski <dan@tuatha.sidhe.org>
Subject: Re: I need a specific release of Perl
Message-Id: <55q56.124271$P82.14446166@news1.rdc1.ct.home.com>
Don <don@lclcan.com> wrote:
> Hi,
> I'm using Perl 5.60 and I've discovered a bug that makes my module
> within my script unusable. I was told by the creator of the module that
> the bug was fixed in version 5.61
> However, when I go to the download sites, all I see is 5.60 or 5.70
> Where can I get 5.61?
What you're looking for is perl 5.6.1, not perl 5.61. It's not quite out
yet, though--probably in the next few weeks.
Dan
------------------------------
Date: Thu, 4 Jan 2001 16:57:33 GMT
From: adelton@fi.muni.cz (Honza Pazdziora)
Subject: Re: Installing dbi dbd on linux
Message-Id: <G6nDrx.4D0@news.muni.cz>
On Thu, 04 Jan 2001 16:23:26 GMT, ljunquera@my-deja.com <ljunquera@my-deja.com> wrote:
> Does anybody know where I can find a step by step guide to installing
> dbi and dbd for oracle on linux red hat 6+.
In the documentation that comes with the DBI and DBD::Oracle
distributions.
Yours,
--
------------------------------------------------------------------------
Honza Pazdziora | adelton@fi.muni.cz | http://www.fi.muni.cz/~adelton/
.project: Perl, DBI, Oracle, MySQL, auth. WWW servers, MTB, Spain.
Petition for a Software Patent Free Europe http://petition.eurolinux.org
------------------------------------------------------------------------
------------------------------
Date: Fri, 5 Jan 2001 22:00:16 GMT
From: "Robert M. Starkweather" <cm142@freenet.buffalo.edu>
Subject: JAPH critique
Message-Id: <G6pMGq.BB0@freenet.buffalo.edu>
hello, all. i am a relative novice to perl (i use it , at my place of
employment for simple database manipulation/reporting), and have fallen
for its inherent style. i've been lurking here for quite a while, and am
mightily impressed by some of the JAPHs posted here (particularly
abigail's). i was hoping some of you would take a moment to critique my
first JAPH creations (all only tested on my unix box at work...hey, it's
been a slow week :) ....with perl version 5.004_04, built for
sun4-solaris).
i know they're kind of ugly, but i'm working on it...i am especially proud
of #3 (an example of extreme laziness).
but will 2 and 3 (which rely on perldoc) work on all systems?
i.e., is the format of perldoc a set standard across systems/versions
of perl?
let me know if they don't work...
perl -e 'split //, "IF A BOY DECIDES TO PLAY WITH PERL, HE BECOMES....";
$a=(join q//, 0, $_[9], $_[10], ord($_[11]), $_[11], 4, 1, $_[10],
$_[10], "010", $_[5], ord("#"), $_[9], ord(","), $_[1],
$_[3], 1, $_[10], $_[5], ord($_[3]), 7, $_[3], 2, $_[10], $=/4,
$_[1], ord(7), 5**2, $_[3], ord(5), $_[10], $_[3]);
while(length $a) {$b=hex(substr $a, 0, 7); substr ($a, 0, 7)="";
split //, $b; @_=("$_[0]$_[1]", "$_[2]$_[3]", "$_[4]$_[5]",
"$_[6]$_[7]"); print (map { (($_==32)&&chr($_))||chr($_+$=) }
@_);} print ",\n";'
perl -e '$_=`perldoc -f split`; @_=split //; $_=join q//, chr((ord
$_[1416])-32), $_[157], $_[2799], $_[4255], $_[4377], $_[4300],
$_[4166], $_[4200], $_[4255], $_[4199], $_[4250], $_[4249],
$_[4377], $_[4356], $_[4250], $_[4249], $_[4243], $_[4377],
$_[4199], $_[4300], $_[4204], $_[3646], $_[4250], $_[4249],
$_[4202], "\n"; print'
perl -e '$_=`perldoc -q JAPH`;($_=substr $_,(index $_,"?")+29,24)=~y/jp/JP/;
print $_,",\n"'
thanks for your time.
------------------------------
Date: 5 Jan 2001 22:56:34 GMT
From: Eli the Bearded <elijah@workspot.net>
Subject: Re: JAPH critique
Message-Id: <eli$0101051742@qz.little-neck.ny.us>
Robert M. Starkweather <cm142@freenet.buffalo.edu> wrote:
> i've been lurking here for quite a while, and am
> mightily impressed by some of the JAPHs posted here (particularly
> abigail's). i was hoping some of you would take a moment to critique my
> first JAPH creations
[..]
> but will 2 and 3 (which rely on perldoc) work on all systems?
> i.e., is the format of perldoc a set standard across systems/versions
> of perl?
The documents change from version to version.
> let me know if they don't work...
Neither of two or three worked right for me. Two printed junk,
three was pretty close but slightly off:
"Just another Perl hack,
> perl -e 'split //, "IF A BOY DECIDES TO PLAY WITH PERL, HE BECOMES....";
> $a=(join q//, 0, $_[9], $_[10], ord($_[11]), $_[11], 4, 1, $_[10],
> $_[10], "010", $_[5], ord("#"), $_[9], ord(","), $_[1],
> $_[3], 1, $_[10], $_[5], ord($_[3]), 7, $_[3], 2, $_[10], $=/4,
> $_[1], ord(7), 5**2, $_[3], ord(5), $_[10], $_[3]);
> while(length $a) {$b=hex(substr $a, 0, 7); substr ($a, 0, 7)="";
> split //, $b; @_=("$_[0]$_[1]", "$_[2]$_[3]", "$_[4]$_[5]",
> "$_[6]$_[7]"); print (map { (($_==32)&&chr($_))||chr($_+$=) }
> @_);} print ",\n";'
I find succinctness an important part. Ideally a JAPH should fit in
Four lines of seventy-nine or fewer characters.
> perl -e '$_=`perldoc -f split`; @_=split //; $_=join q//, chr((ord
> $_[1416])-32), $_[157], $_[2799], $_[4255], $_[4377], $_[4300],
> $_[4166], $_[4200], $_[4255], $_[4199], $_[4250], $_[4249],
> $_[4377], $_[4356], $_[4250], $_[4249], $_[4243], $_[4377],
> $_[4199], $_[4300], $_[4204], $_[3646], $_[4250], $_[4249],
> $_[4202], "\n"; print'
This just shouts out for some other way to store and use those numbers.
> perl -e '$_=`perldoc -q JAPH`;($_=substr $_,(index $_,"?")+29,24)=~y/jp/JP/;
> print $_,",\n"'
Try grabbing based on context, rather than exact positions.
Elijah
------
sub S(){@s=caller($/);$s[3]=~s s\w+:+ss&&print$s[3].q. .}$/=$^=~s/\S+/\n/;
$_="Just (eli) Another (the) Perl (bearded) Hacker";sub s($){eval$_[0];$/}
while(s&&&&& &s(qq&sub$^&.$&.q&{\&S}&)&& &{$&}&&s&&&){$/}$\=$^;print"\b,";
------------------------------
Date: Fri, 05 Jan 2001 20:18:46 +0100
From: Clifford Pennock <cliff@*MYLASTNAMEHERE*.nl>
Subject: Just how experimental *is* Multithreading?
Message-Id: <9357eo$orm$1@news.news-service.com>
I am writing a Perl script that could benefit greatly from threading.
I'm currently using version 5.005 and I am thinking about installing
5.6.0 instead. But in the 5.6.0 readme it says threads are still very
experimental and should *not* be used for production. Before I further
install 5.6.0 and rewrite a large part of the script, is there anyone
here that is willing to share their experiences with me regarding
threading in 5.6.0? Is it really that unreliable?
TIA,
- Cliff
------------------------------
Date: Fri, 05 Jan 2001 20:12:24 GMT
From: Dan Sugalski <dan@tuatha.sidhe.org>
Subject: Re: Just how experimental *is* Multithreading?
Message-Id: <IUp56.124270$P82.14444681@news1.rdc1.ct.home.com>
Clifford Pennock <cliff@*mylastnamehere*.nl> wrote:
> I am writing a Perl script that could benefit greatly from threading.
> I'm currently using version 5.005 and I am thinking about installing
> 5.6.0 instead. But in the 5.6.0 readme it says threads are still very
> experimental and should *not* be used for production. Before I further
> install 5.6.0 and rewrite a large part of the script, is there anyone
> here that is willing to share their experiences with me regarding
> threading in 5.6.0? Is it really that unreliable?
5.6.0's threading is still unstable--there are some race conditions
and unsynchrnized shared data access inside the core that can bite
you. 5.6.1 should have all the known problems, with the exception
of regex match variables, fixed. It's still rather slow in spots
and threading in the 5.x tree will probably never get as robust
as you might like. (That's something that'll end up waiting
for perl 6, because it requires a fairly significant rewrite
of chunks of the guts, and since we're doing that for perl 6
anyway...)
Dan
------------------------------
Date: Fri, 05 Jan 2001 19:15:26 GMT
From: Adrian Jackson <no@spam.com>
Subject: Match a reg.ex. EXCEPT inside quotes?
Message-Id: <t65c5t4v5cb2vhseu5s9p2iv3f8vfc3lqt@4ax.com>
I'm still working on beautifying that BASIC source code. Right now
I'm wanting to pick out all the keywords so I can do various
contextual things to them. The problem, again, is that sometimes a
keyword also happens to be an English word that appears within quotes.
One easy example is the keyword "and".
I would want to catch these ANDs...
1211 IFTN=8ANDVC=5ANDST%(36)>29THEN1280
...but not this one:
5124 PRINT" YOU SUDDENLY PERCEIVETHAT THE DRAGON IS ALIVE AND
STARING"
My idea was to use a regular expression to match either a chunk of
quoted text, or a chunk of non-quoted text. So I was using:
# $expr was assigned to a line of BASIC source code.
while ($expr=~/(".*?")|([^\"]*)/ig) {
if (substr($1, -1, 1) ne "\"") {
print("PASS: $1\n");
} else {
print("FAIL: $1\n");
}
}
For some reason, all the quoted text (FAIL) makes it out in one piece,
but all the non-quoted text (PASS) is (I assume) diced into the
so-called "nothings" between the letters (and the "nothings" are all
that end up in $1). I've messed around with that reg.ex. quite a
bit*, and looked over the reg.ex. part of the faq, but to no avail.
Is there a way to do this with regular expression, or if not, at least
succinctly? (Succinctly, otherwise I might as well write my own
parser in C, a language I know much better than Perl.)
* (including just using the ([^\"]*) portion, which oddly enough DOES
put chunks of non-quoted text in $1 [as well as non-quoted versions of
text within quotes])
------------------------------
Date: 5 Jan 2001 19:53:06 GMT
From: Ilmari Karonen <iltzu@sci.invalid>
Subject: Re: Match a reg.ex. EXCEPT inside quotes?
Message-Id: <978724083.20470@itz.pp.sci.fi>
In article <t65c5t4v5cb2vhseu5s9p2iv3f8vfc3lqt@4ax.com>, Adrian Jackson wrote:
>I'm still working on beautifying that BASIC source code. Right now
>I'm wanting to pick out all the keywords so I can do various
>contextual things to them. The problem, again, is that sometimes a
Take my advice -- don't do this with regexen. Write a grammar for the
language you're parsing, and use a real parser. Parse::RecDescent and
Parse::Yapp are two modules you should look into.
It'll save you a lot of grief later.
--
Ilmari Karonen -- http://www.sci.fi/~iltzu/
"Get real! This is a discussion group, not a helpdesk. You post
something, we discuss its implications. If the discussion happens to
answer a question you've asked, that's incidental." -- nobull in clpm
------------------------------
Date: Fri, 5 Jan 2001 12:58:03 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Match a reg.ex. EXCEPT inside quotes?
Message-Id: <slrn95c2pb.q9b.tadmc@magna.metronet.com>
Adrian Jackson <no@spam.com> wrote:
>The problem, again, is that sometimes a
>keyword also happens to be an English word that appears within quotes.
>One easy example is the keyword "and".
>
>I would want to catch these ANDs...
>
>1211 IFTN=8ANDVC=5ANDST%(36)>29THEN1280
>
>...but not this one:
>
>5124 PRINT" YOU SUDDENLY PERCEIVETHAT THE DRAGON IS ALIVE AND
>STARING"
>
>My idea was to use a regular expression to match either a chunk of
>quoted text, or a chunk of non-quoted text. So I was using:
>
># $expr was assigned to a line of BASIC source code.
>while ($expr=~/(".*?")|([^\"]*)/ig) {
^^^^^^^^
^^^^^^^^ there is $2
You have multiple problems all rolled into a single regex,
very efficient :-)
First, you should *always* develop Perl code with warnings
enabled, it would have pointed out some problems here.
Next, why bother remembering things in $2 if you never access $2?
The second part of the alternation matches the empty string
(what you call "nothings" below). *Every* string contains
the empty string, so that pattern must match all strings!
What effect do you expect the m//i option to have? It can have
no effect whatsoever with your pattern. Options that don't do
anything should not be used. You are dipping into cargo cult
programming it appears.
Double quotes are not special in character classes (or in regexes either),
so they should not be backslashed.
You don't need a not-a-quote character class, dot will work fine
because perl matches left-to-right, so it will match a quoted
string first if it can.
while ( /((".*?")|(.+))/ig ) {
^ ^ there is $1
or, use the $+ variable instead of $1:
while ( /(".*?")|(.+)/ig ) {
if (substr($+, -1, 1) ne '"' ) {
...
> if (substr($1, -1, 1) ne "\"") {
Use single quotes to avoid annoying backslashes:
if ( substr($1, -1, 1) ne '"' ) {
--
Tad McClellan SGML consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Fri, 5 Jan 2001 14:08:22 -0600
From: "Neil" <neil@alaweb.com>
Subject: Net::Telnet and --More--
Message-Id: <t5cadgp531d44a@corp.supernews.com>
Hi Folks,
I am having a problem using Net::Telnet when accesing a Cisco router....
When I run this code... which is a sub in a larger program ... so please
note that all the variables are defined earlier....
my $box_prompt = $ras_box;
$box_prompt = '/[\$%#>]$/';
my $this_session =
Net::Telnet->new(Host=>$ras_box,Errmode=>&write_error_kick_log,Prompt=>$box_
prompt);
my $fh = $this_session->input_log("C:\\logs\\input.log");
my $ok = $this_session->login
(Name=>$script_username,Password=>$script_password);
$ok = $this_session->print("who");
my $done = 0;
my $line = "";
my $more = '--More--';
while (!($done))
{
$line = $this_session->getline();
if ($line =~ /$more/);
{
$ors = $this_session->output_record_separator("");
$ok = $this_session->print(" ");
$ors = $this_session->output_record_separator("\n");
$done = 1;
}
}
It hangs....I was using @array=$this_session->cmd("who") but changed it to
this to hopefully work out getting around the --More-- that the Cisco router
is sending back ... and waiting for a <SPACE> as input to continue....
I have looked at the input.log ... and it is the --More-- that is causing
the problems.....
Any help is greatly appreciated.
Thanks,
Neil
------------------------------
Date: Fri, 05 Jan 2001 20:56:18 GMT
From: cputek1@my-deja.com
Subject: New to perl question about traversing directories and searching for files.
Message-Id: <935cde$6pk$1@nnrp1.deja.com>
I'm not looking for the answer to this question.. Just want to be
pointed in the right direction (I'll never learn if I'm just told the
answer)... My question is...
I need to search for files with a certain extention
(.exe, .dll, .jar, .class) in a directory and all sub directories.
From there I need to move those files out to another directory
maintaining the path. I also need to save that directory/filename into
a an output file so that I can remove the binary from our repository
using the output file as the dataset. The problem that I have bashed
my head into (a few times) is that I can traverse the directory with
the following script (taken from Perl book)...
#!/usr/bin/perl -lw
# fdirs - find all directories
@ARGV = qw(.) unless @ARGV;
use File::Find ();
sub find(&@) { &File::Find::find }
*name = *File::Find::name;
find { print $name if -d } @ARGV;
but getting it to search for the extentions in those directoryies is
another issue. Once I can get the directory path and the filename into
a variable the rest should be no problem.
any ideas...
thank you so much..
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: Fri, 05 Jan 2001 18:58:21 GMT
From: woodywit@my-deja.com
Subject: Re: perl and zombies
Message-Id: <9355g9$ba$1@nnrp1.deja.com>
In article <934kg8$pbc$11@mamenchi.zrz.TU-Berlin.DE>,
anno4000@lublin.zrz.tu-berlin.de (Anno Siegel) wrote:
> Martien Verbruggen <mgjv@tradingpost.com.au> wrote in
comp.lang.perl.misc:
> >On Fri, 05 Jan 2001 13:21:09 GMT,
> > Mark Jason Dominus <mjd@plover.com> wrote:
> >> In article <934bjr$pbc$4@mamenchi.zrz.TU-Berlin.DE>,
> >> Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> wrote:
> >>>It doesn't for me (perl 5.003 on Solaris), and there's no reason
why
> >>>it should.
> >>
> >> I get the defunct process with 5.6 on linux.
> >
> >perl 5.6 on linux 2.2.16-3, glibc 2.1.3, no defunct processes:
> >
> >#!/usr/local/bin/perl -w
> >use strict;
> >open(TIME, "/bin/date |") or die "Can't fork: $!";
> >my @time = <TIME>;
> >close(TIME) or die "Can't close pipe: $!";
> >system 'ps -ef | grep defun';
> >
> >I also don't see them if I put a long sleep there, and check from
> >another window.
>
> Curiouser and curiouser. Running your code literally (well, I have
> to say "ps aux" instead of "ps -ef") I don't see a zombie either,
> in multiple tries.
>
> perl 5.006, linux 2.0.36, libc 2.0.7.
>
> Anno
>
Try this one out for size. I get a zombie every time.
#!/bin/perl -w
open(TIME, "/bin/date |") or die "can't fork: $!";
print "Pipe open\n";
my @time=<TIME>;
if (`ps -ef` =~ /defunct/ )
{ print "Caught me a zombie\n";}
close(TIME) or die "Can't close pipe: $!";
print "Pipe closed\n";
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: Sat, 6 Jan 2001 09:44:46 +1100
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: perl and zombies
Message-Id: <slrn95cjiu.suo.mgjv@martien.heliotrope.home>
On Fri, 05 Jan 2001 14:28:27 GMT,
Mark Jason Dominus <mjd@plover.com> wrote:
> In article <slrn95bm06.suo.mgjv@martien.heliotrope.home>,
> Martien Verbruggen <mgjv@tradingpost.com.au> wrote:
>>It's a bug, but I'd probably call it a minor one. Not checking for
>>errors causes problems :)
>
> I don't think you have thought this through. "Not checking for
> errors" is irrelevant. Change the 'die' to 'warn' and it still leaves
> a zombie.
Which is what I did, and how I confirmed the bug. I should maybe have
said 'Not taking appropriate action leaves a zombie'. However, even that
would have been wrong:
It is possible to think up a long running process that fires off
something in /usr/local/bin now and again, say every 5 seconds. Someone
installs a new version of the tool, but now it lives in /usr/bin. The
program starts failing to execute the old version of the binary, via
system, and faithfully logs this in a log file somewhere. A few days
later the machine runs out of process slots.
You're right. It's a bug that needs to be fixed.
Martien
--
Martien Verbruggen |
Interactive Media Division | The world is complex; sendmail.cf
Commercial Dynamics Pty. Ltd. | reflects this.
NSW, Australia |
------------------------------
Date: Sat, 6 Jan 2001 09:47:25 +1100
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: perl and zombies
Message-Id: <slrn95cjnt.suo.mgjv@martien.heliotrope.home>
On Fri, 05 Jan 2001 18:58:21 GMT,
woodywit@my-deja.com <woodywit@my-deja.com> wrote:
> Try this one out for size. I get a zombie every time.
>
> #!/bin/perl -w
>
> open(TIME, "/bin/date |") or die "can't fork: $!";
> print "Pipe open\n";
> my @time=<TIME>;
> if (`ps -ef` =~ /defunct/ )
> { print "Caught me a zombie\n";}
> close(TIME) or die "Can't close pipe: $!";
This is where the process gets waited on. I bet that if you check
_after_ the close you won't find the zombie. The original complaint was
that the zombies remained after the close, until the program terminates.
See the parallell thread in which MJD tells us all why :)
Martien
--
Martien Verbruggen |
Interactive Media Division | Begin at the beginning and go on till
Commercial Dynamics Pty. Ltd. | you come to the end; then stop.
NSW, Australia |
------------------------------
Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 16 Sep 99)
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.
| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V10 Issue 2
************************************