[18657] in Perl-Users-Digest
Perl-Users Digest, Issue: 825 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu May 3 00:06:01 2001
Date: Wed, 2 May 2001 21:05:12 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <988862712-v10-i825@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Wed, 2 May 2001 Volume: 10 Number: 825
Today's topics:
Re: $Response->printf ("my float rounded up to 2 dp."); <justin.devanandan.allegakoen@intel.com>
ActiveState config problem <fredkarp@earthlink.net>
Re: Algorithm ? <jhall@ifxonline.com>
Re: Algorithm ? <dkoleary@mediaone.net>
Re: Algorithm ? <dkoleary@mediaone.net>
blank lines on asp using PerlScript <justin.devanandan.allegakoen@intel.com>
Re: Color <kdalal@students.uiuc.edu>
Compiling perl for SCO <nigelb@thedairy.au.com>
fork and keep multi process when any child exit ? (dekuo)
Re: How to enclose scalar for readability? <lagaly@eskimo.com>
How to use Sendmail running on a different box <j2lab@my-deja.com>
Re: How to use Sendmail running on a different box <tony_curtis32@yahoo.com>
Re: How to: Create Regex which extracts N number of wor (Richard J. Rauenzahn)
Re: HTML::LinkExtor (installing perl modules) <zakaria1@hotmail.com>
Limit on argument length in pipe <pln@cosmic.stanford.edu>
NT version of LWP::UserAgent <smilepak@hotmail.com>
Perl and uClibc <pally@axtronics.com.tw>
Perl for Dreamweaver Extension Posted <notmyrealemail@example.com>
Re: Please help! <pailhead@tampabay.rr.com>
Re: Prevent warning: check for open file handle? (Anno Siegel)
Re: Problem with "require" in server (Anno Siegel)
Re: Question about float to hex (Martien Verbruggen)
Re: Question about float to hex (Richard J. Rauenzahn)
Re: Recursing a directory tree <centreman_19@NOSPAMyahoo.com>
Re: Recursing a directory tree (Anno Siegel)
Re: RegExp Teaser <abe@ztreet.demon.nl>
Re: Removing blank lines from end of data (Anno Siegel)
Re: Removing blank lines from end of data (F. Xavier Noria)
Re: Removing blank lines from end of data <Jonathan.L.Ericson@jpl.nasa.gov>
Running perl script on the DOS prompt (Windows) <brunopagis@earthlink.net>
Re: Running perl script on the DOS prompt (Windows) <justin.devanandan.allegakoen@intel.com>
Re: Should Perl be first? <billy@localhost.net>
Re: Should Perl be first? (Mark Jason Dominus)
Re: Simple newbie performance question <tom.beer@btfinancialgroup.spamfilter.com>
test <alex2@andrew.cmu.edu>
Unix Process Test <petethsc@mindspring.com>
Re: Unix Process Test <krahnj@acm.org>
Uploading to http sites <mail@NOSPAMericmarques.net>
Re: Windows Komodo users get input on debug? <"relaxedrob@optushome.com.au">
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 2 May 2001 17:30:26 +0800
From: "Just in" <justin.devanandan.allegakoen@intel.com>
Subject: Re: $Response->printf ("my float rounded up to 2 dp.");
Message-Id: <9cqg4c$42n@news.or.intel.com>
Malte was kind enoungh to point me in the right direction with an example to
boot - thanks.
FAQ says use printf or sprintf, it didnt tell me I could stick it in
$Response->Write.
I didnt have the slightest inkling that I could stick it in. I'm not very
adventurous when it
comes to this sort of thing, and FAQ didnt really address this in a way that
a dumbo like
me could understand ; )
------------------------------
Date: Thu, 03 May 2001 02:07:09 GMT
From: Fred Karp <fredkarp@earthlink.net>
Subject: ActiveState config problem
Message-Id: <3AF0BD47.925EAC78@earthlink.net>
An upgrade installation of Perl 5.6.0.623 a couple of weeks ago rendered
previously-working scripts inaccessible. The path on the NT 4 server is
c:\perl\bin, where the exe resides. A test script located in the
\inetpub\wwwroot\myMain\cgi-bin directory executes properly on the web, but
anywhere else (including \inetpub\wwwroot\myMain) they yield a 403.1 Execute
access forbidden error. The permissions for both directories are identical:
Everyone has Read/Execute.
What did or didn't I do?
- Fred Karp
karp@uscj.org
http://www.uscj.org
------------------------------
Date: Wed, 02 May 2001 22:08:39 GMT
From: "John Hall" <jhall@ifxonline.com>
Subject: Re: Algorithm ?
Message-Id: <Hz%H6.1220$t27.42743@news1.rdc1.sdca.home.com>
I'm not going to assault you with 'did you read this novel, did you read
that novel..'
Here's a good article describing 'tethering' and keeping track of many
children..
http://www.stonehenge.com/merlyn/LinuxMag/col15.html
"Doug O'Leary" <dkoleary@ro05-24-29-232-217.ce.mediaone.net> wrote in
message news:tlZH6.72$qPc.4587693@news.randori.com...
> Hey, all;
>
> I know there's a clever way to do what I need to do; I'm just not
> clever enough to figure it out on my own...
>
> I have a file containing 600+ entries on which I need to do the
> same process. Running through the entire file sequentially takes too
> long, so I want to parallelize the processing to a degree that's
> user specified (either on cmd line or as variable - that part's moot).
>
> I know I'm going to have to fork/exec processes. Although I'm not
> *real* comfortable with the syntax, I've done it and can figure it
> out again.
>
> The part I'm having a problem with is how to limit the processing. If
> the outer loop is reading the file, I have 600+ children which is a
> tad ... excessive.
>
> If I loop through the index, then how do I know when I can kick off
> another child? For instance:
>
> while (<In>)
> { for ( $index = 0; $index < $degree; $index++)
> { next if $pid = fork;
> die "fork: ($!)" if ! defined $pid;
> ### child processing
> }
> }
>
> How do I stop the thing from looping until at least one of the
> child processes has died?
>
> Along those same lines, how do I keep the other children looping if
> one of those puppies hangs for awhile?
>
> Any hints/tips would be greatly appreciated.
>
> Thanks for your time.
>
> Doug
>
> --
> ------------------------
> Douglas K. O'Leary
> Senior System Administrator
> dkoleary@mediaone.net
------------------------------
Date: Wed, 2 May 2001 18:15:15 -0700
From: Doug O'Leary <dkoleary@mediaone.net>
Subject: Re: Algorithm ?
Message-Id: <MPG.155a50fca4418f76989790@news.randori.com>
In article <Hz%H6.1220$t27.42743@news1.rdc1.sdca.home.com>,
jhall@ifxonline.com says...
I'm not going to assault you with 'did you read this novel, did you read
that novel..'
I appreciate that no end!
Here's a good article describing 'tethering' and keeping track of many
children..
http://www.stonehenge.com/merlyn/LinuxMag/col15.html
Thanks for the link. From the overview, it looks even more indepth than
what I'm looking for, but it'll get me going.
Thanks again.
Doug
--
-------------------
Douglas K. O'Leary
Senior System Administrator
dkoleary@mediaone.net
------------------------------
Date: Wed, 2 May 2001 18:22:20 -0700
From: Doug O'Leary <dkoleary@mediaone.net>
Subject: Re: Algorithm ?
Message-Id: <MPG.155a52a8eef6f265989791@news.randori.com>
Hey;
Then, I have a count of forked processes. Whenever I succeed in
forking one, I increase the count. Also, whenever I call wait() and
find out that a child process has finished, I decrease the count.
Thanks for the tips. After leaving work, I was pondering a solution
similar to that; haven't had a chance to try it out yet though. That
should help me circumvent a few extra hours of work...
Notice that the stuff at the end of the loop is an "if" and not a
while. This ensures that you don't end up waiting on *all* your tasks
to finish before you try to start additional ones.
I was still on the "while" in my ponderings - that's a good point.
Thanks again! You've been a big help.
Doug
--
-------------------
Douglas K. O'Leary
Senior System Administrator
dkoleary@mediaone.net
------------------------------
Date: Thu, 3 May 2001 11:02:45 +0800
From: "Just in" <justin.devanandan.allegakoen@intel.com>
Subject: blank lines on asp using PerlScript
Message-Id: <9cqhoo$52u@news.or.intel.com>
I do believe I'm stuck yet again.
I'm using PerlScript for an asp, the file handling and
processing of the file occur before the actual
table is displayed.
But before the table is printed on the asp there are a
whole heap of blank lines printed for no apparent
reason. (It seems they are proportional to the
amount of rows in the table).
Viewing the source HTML doesnt help - I can't see
any dead give aways like extra <P>'s or <BR>'s
Funny thing is when you select these blank lines, the
rows on the table get selected for every blank line
you select. Are the $Response-Write's doing
anything extra?
Appreciate any feedback.
Thanks
------------------------------
Date: Wed, 2 May 2001 17:48:30 -0500
From: karan shishir dalal <kdalal@students.uiuc.edu>
Subject: Re: Color
Message-Id: <Pine.GSO.4.31.0105021747390.24975-100000@ux12.cso.uiuc.edu>
Will do! Thanks
Karan
----- BEGIN GEEK CODE BLOCK -----
Version 3.1
GCS/CM d-(?) s: a--->? C+++(++) U>++
L+>++++ W++ n+++(+) o? K? w++>$ O--- M--
V! PS+ PE++ Y? PGP-- t- 5? X R*@ tv--()
b+(+++) DI D---- G e>+++++>$ !r> y--*
------ END GEEK CODE BLOCK ------
On Wed, 2 May 2001, Ron Hill wrote:
> karan shishir dalal wrote:
>
> > Just need some help on how i could include colors to my output in my
> > script.
> [snipped]
>
> For windows NT
> you need to use Win32::Console
>
> For unix
> use Term::ANSIColor
>
> I hope this helps
>
> Ron Hill
>
------------------------------
Date: Thu, 03 May 2001 00:26:47 GMT
From: Nigel S. Ball <nigelb@thedairy.au.com>
Subject: Compiling perl for SCO
Message-Id: <bB1I6.30501$ff.225599@news-server.bigpond.net.au>
Has anyone managed to compile perl for SCO using the UDK rather than the
Openserver Dev Kit? I can do the latter but need a perl compiled on OSR5
for UnixWare.
Any help would be appreciated (eg hints file) or just a copy of a good
config.sh which I can review.
Thanks in advance,
--
Nigel S. Ball
nigelb@thedairy.au.com
------------------------------
Date: 3 May 2001 07:34:42 +0800
From: dekuo@hello.com.tw (dekuo)
Subject: fork and keep multi process when any child exit ?
Message-Id: <9cq5ha$1i8$1@news.ethome.net.tw>
I find that this program can not do some thing with parent ?
I have a sample code just only fork one process but it can check now in which process.
===============================================================
if (!defined($kidpid=fork())) {
die "can not fork\n";
}
if ($kidpid == 0) {
# fork returned 0, so this branch is the child
print "PID=$kidpid\n\n";
sleep 30;
exit;
}
else {
# fork returned neither 0 nor undef,
# so this branch is the parent
print "PID=$kidpid\n\n";
waitpid($kidpid, 0);
}
=================================================================
I want the parent to keep 5 child process and child cna do something when one die or exit.
How to do that ?
(I want use Perl standard module to complete this program)
(Jonathan Stowe) gellyfish@gellyfish.com wrote:
>dekuo <dekuo@hello.com.tw> wrote:
>> How to use fork() system function to fork multi child process at the same time ?
>>
>> For example:
>>
>> Run a program to fork 5 child process at the same time and the parent must wait
>> until all child exit.
>>
>
>This shows the principle :
>
>
>for ( 1 .. 5 )
>{
> unless ( fork )
> {
> sleep 5;
> print "child $_ exiting\n";
> exit 0;
> }
>}
>
>1 while( wait > 0 );
>print "All children finished\n";
>
>read the perlfunc entries for fork() and wait().
>
>/J\
-- CNews 0.39
------------------------------
Date: Wed, 2 May 2001 19:03:33 -0700
From: "Michael LaGaly" <lagaly@eskimo.com>
Subject: Re: How to enclose scalar for readability?
Message-Id: <9cqdun$7qp$1@eskinews.eskimo.com>
"Marc" <nobody@nobody.com> wrote in message
news:nobody-47C630.14255726042001@news.rcn.com...
> Is there a way to enclose a scalar variable for both readability and
> parsing reasons?
>
> For example:
>
> print "This is the two variables I want $together$here"
>
> Is there some way to enclose these so they are not together and will
> print ok still. Especially if I have a variable named $together and
> maybe one called $togethe (and I want the "r" to print between $togethe
> and $here)
$togethe="a";
$here="e";
print "This is the two variables I want $togethe" . "R" . "$here";
This prints:
This is the two variables I want aRe
------------------------------
Date: Wed, 02 May 2001 17:10:52 -0700
From: John Smith <j2lab@my-deja.com>
Subject: How to use Sendmail running on a different box
Message-Id: <3AF0A20C.80C13EC4@my-deja.com>
I was curious if there is a way to use another machine's Sendmail. I
have two boxes, a mail server (Box A) and a workstation (Box B). I'm
running a script on Box B that sends email out. What I want to do is
completely disable Sendmail on Box B. This machine really has no need
to run Sendmail ever. Is there a way for me to open a pipe to Box A and
use that machine's Sendmail?
Any help would be greatly appreciated.
John
------------------------------
Date: 02 May 2001 19:24:25 -0500
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: How to use Sendmail running on a different box
Message-Id: <87bspbi8jq.fsf@limey.hpcc.uh.edu>
>> On Wed, 02 May 2001 17:10:52 -0700,
>> John Smith <j2lab@my-deja.com> said:
> I was curious if there is a way to use another machine's
> Sendmail. I have two boxes, a mail server (Box A) and a
> workstation (Box B). I'm running a script on Box B that
> sends email out. What I want to do is completely
> disable Sendmail on Box B. This machine really has no
> need to run Sendmail ever. Is there a way for me to
> open a pipe to Box A and use that machine's Sendmail?
Are you talking about sendmail running as an SMTP server
or just as an injector?
In the former case, you can run sendmail in daemon mode on
A and use Net::SMTP (perl relevance! :-) to connect to it
from B.
Otherwise, configure sendmail on box B to point to a
smarthost suitably set up for your local network (this
might be machine A of course). Use Mail::Sendmail or
similar client on B.
news:comp.mail.sendmail for this configuring this option
as it's way outside the scope of perl.
hth
t
--
Just reach into these holes. I use a carrot.
------------------------------
Date: 3 May 2001 00:49:32 GMT
From: nospam@hairball.cup.hp.com (Richard J. Rauenzahn)
Subject: Re: How to: Create Regex which extracts N number of words before target word
Message-Id: <988850972.229559@hpvablab.cup.hp.com>
"BarryK" <notmyrealemail@example.com> writes:
>Rich, I took your implicit suggestion to reverse the order of "\w\W", but
>Bart pointed out a great counterexample which breaks the regex:
But now you've also changed your requirements from a replacement
expression to a matching expression. This still works as I would expect
it to -- I don't know what you expect:
#!/usr/bin/perl -w
use strict;
$_ = "word1 word2 word3 word4 cat word5 cat word6 word7 word8";
s/(\w+\W+){2}cat(\W+\w+){2}/Z/;
print $_;
word1 word2 Z word6 word7 word8
>== START CODE ===
>
>$string = "word1 word2 word3 cat word5 cat word7 word8 word9";
>
>@matches = ($string =~ m |(\w+ \W+){2}cat(\W+ \w+){2} |xg);
>
>print join ("\n", @matches);
>
>== END CODE =====
>
>THIS SHOULD RETURN:
>
>word2 word3 cat word5 cat
>cat word5 cat word7 word8
>
>BUT INSTEAD RETURNS:
>
>word3
> cat
Of course -- because a regex will return what you 'captured' in the
()'s. Try it again with m|((\w+ \W+){2}cat(\W+ \w+){2})|xg
^ ^
Now the tricky part which Bart was probably pointing out is that after
you've captured the first cat, you're now past the second one. You
somehow need to back up. I'm not familiar with doing that in RE's, so I
won't offer a solution using RE's. At this point, I'd personally use an
RE to split up the words and use an array and a simple algorithm to find
the matches:
#!/usr/bin/perl -wl
use strict;
my $t = "word1 word2 word3 cat word5 cat word7 word8 word9 cat word11";
@_ = split(/\W+/, $t);
my @s;
my $b = 2; # number of before words
my $a = 2; # number of after words
foreach (@_) {
push(@s, $_);
if(@s == $b+$a+1) {
print "@s" if($s[$b] eq 'cat');
shift @s;
}
}
Rich
--
Rich Rauenzahn ----------+xrrauenza@cup.hp.comx+ Hewlett-Packard Company
Technical Consultant | I speak for me, | 19055 Pruneridge Ave.
Development Alliances Lab| *not* HP | MS 46TU2
ESPD / E-Serv. Partner Division +--------------+---- Cupertino, CA 95014
------------------------------
Date: Wed, 02 May 2001 20:06:35 -0400
From: zaki <zakaria1@hotmail.com>
Subject: Re: HTML::LinkExtor (installing perl modules)
Message-Id: <3AF0A10B.A69EF689@hotmail.com>
Thank you Jon,
I went to CPAN and downloaded the module it was complaining about and it
worked. Only a small detail bothers me. i couldnt follow the intructions
for installing the modules. It gave me an error message about the
command 'make', so i just copied the file 'Tagset.pm' to the HTML
directory in lib folder and it worked...so whats the difference between
installing and copying modules...i never installed a module in linux, i
used to use PPM in windows or just copy the module where it will be seen
by perl...Whats the difference?
Thanks a lot.
------------------------------
Date: 2 May 2001 22:32:44 GMT
From: "Patrick L. Nolan" <pln@cosmic.stanford.edu>
Subject: Limit on argument length in pipe
Message-Id: <9cq1uc$k4u$1@nntp.Stanford.EDU>
I have a script which includes a line like this:
open (MAIL, "| /usr/lib/sendmail $addresslist") or die;
$addresslist is a string which contains a series of e-mail addresses
separated by commas. It works OK for my test cases, but I worry
that real life operation may produce a list that's too big to
handle.
Does anyone know what sort of limits apply to this situation?
If it makes a difference, it's perl version 5.005_03 on Red Hat
Linux 6.2.
--
* Patrick L. Nolan *
* W. W. Hansen Experimental Physics Laboratory (HEPL) *
* Stanford University *
------------------------------
Date: Thu, 03 May 2001 00:01:33 GMT
From: "smilepak" <smilepak@hotmail.com>
Subject: NT version of LWP::UserAgent
Message-Id: <xd1I6.3108$Cq3.285904@newsread1.prod.itd.earthlink.net>
anyone know if there is a version of LWP::UserAgent for the NT version of
Perl? If so, where and how can I obtain a copy of it?
KN
------------------------------
Date: Thu, 3 May 2001 11:43:20 +0800
From: "Pally Kuo" <pally@axtronics.com.tw>
Subject: Perl and uClibc
Message-Id: <9cqk0a$1di4$1@ccreader.nctu.edu.tw>
Hello,
Does anybody use perl interpreter with uClibc (without glibc) in embed
system ?
I met some troubles when compiling perl interpreter...
------------------------------
Date: Thu, 03 May 2001 03:50:42 GMT
From: "BarryK" <notmyrealemail@example.com>
Subject: Perl for Dreamweaver Extension Posted
Message-Id: <mA4I6.52498$U4.12353065@news1.rdc1.tn.home.com>
Macromedia has announced a Perl for Ultradev extension. I have no idea what
it does, but if you have Ultradev I suspect it's powerful. You can get it
at:
http://www.macromedia.com/exchange/ultradev/
If you can explain to me a) what it does and b) how to use it, I'd be in
your debt.
------------------------------
Date: Thu, 03 May 2001 01:13:54 GMT
From: "Jason Pratt" <pailhead@tampabay.rr.com>
Subject: Re: Please help!
Message-Id: <mh2I6.165130$o9.22535700@typhoon.tampabay.rr.com>
Funny... dude.. I don't know CGI, I don't know how to program in CGI. I"m
just looking for a simple script that can help me out. Oh well, guess I
won't get the help here just sarcasm.
Sorry to waste your time and mine.
"Godzilla!" <godzilla@stomp.stomp.tokyo> wrote in message
news:3AF07C3A.3D4512CD@stomp.stomp.tokyo...
> Jason Pratt wrote:
>
> > I have checked all of the repositories, what key words should I use?
What
> > category would this type of script fall under?
>
> > Please help me out....
>
>
> Excuse me? Have malicious aliens from a parallel
> universe robbed you of your gray matter?
>
> Noting you are able to formulate, type and post
> a response, my presumption is you are not totally
> flat line and still capable of a measured degree
> of cognitive thought. Try thinking in lieu of
> filing a missing gray matter report with Frank
> Zappa's Brain Police.
>
> I provided you with decent advice and a script which
> provides a basis for what you want to do. What? You
> want me to now perform Pocahontas nude cartwheels
> for you?
>
> Godzilla!
>
------------------------------
Date: 2 May 2001 22:48:00 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Prevent warning: check for open file handle?
Message-Id: <9cq2r0$pfa$2@mamenchi.zrz.TU-Berlin.DE>
According to Greg Bacon <gbacon@hiwaay.net>:
> In article <988824646.149539@irys.nyx.net>,
> Avinash Chopde; <avinash@acm.org> <avinash@acm.org> wrote:
>
> : Is there a way to check if a filehandle is valid in perl?
> : print FH "xxx" if (FH is valid);
> :
> : It all still works, I'm only trying to stop the warning
> : about print to invalid filehandle showing up in STDERR
> : (am running with -w)
>
> IO::Handle has an opened() method to check this:
[snip demo]
Alternatively, "defined fileno FH" can be used.
Otherwise, I wonder if trying to write to a closed filehandle
isn't a sign of a bug that should be repaired. Normally you
wouldn't install a signal handler in %SIG before everything is
set up for it to run (which would include opening the file).
Likewise, you'd remove the handler before you close the file.
Is that a possibility?
Anno
------------------------------
Date: 2 May 2001 23:03:42 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Problem with "require" in server
Message-Id: <9cq3oe$pfa$3@mamenchi.zrz.TU-Berlin.DE>
According to Mr. Sunray <djberge@uswest.com>:
> Ok - figured out my own problem. As per advice from Lincoln Stein's NPWP,
> I set the current working directory to '/' once the server starts. I
> forgot about that. Once that happened, it was then looking in the root
> directory rather than the Server's directory for the module.
This doesn't sound like a solution. Are you saying the the server
(whatever it is) will always have the directory it resides in for its
current directory? This is not something to rely on. You should
consider the module FindBin, which gives you the directory of your
script, independent of the quirks of the operating system.
Anno
------------------------------
Date: Thu, 03 May 2001 02:19:58 GMT
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: Question about float to hex
Message-Id: <slrn9f1g2e.4mi.mgjv@verbruggen.comdyn.com.au>
On Wed, 02 May 2001 04:03:35 GMT,
Dodger <dodger@necrosoft.net> wrote:
> "Richard J. Rauenzahn" <nospam@hairball.cup.hp.com> wrote in message
> news:988757459.310084@hpvablab.cup.hp.com...
>> toaster <toaster@nomail.org> writes:
>> perl -e'print sprintf("0x%x", unpack("L", pack("f", 42.1234)))'
>
> Not bad, but I do have to ask: why are we saying print sprintf?
Because some people just don't like all that high level functionality
that things like printf give you.
Martien
I'm sure there's an implied smiley in there somewhere.
--
Martien Verbruggen |
Interactive Media Division | If at first you don't succeed,
Commercial Dynamics Pty. Ltd. | destroy all evidence that you tried.
NSW, Australia |
------------------------------
Date: 2 May 2001 21:45:05 GMT
From: nospam@hairball.cup.hp.com (Richard J. Rauenzahn)
Subject: Re: Question about float to hex
Message-Id: <988839904.514196@hpvablab.cup.hp.com>
"Dodger" <dodger@necrosoft.net> writes:
>"Richard J. Rauenzahn" <nospam@hairball.cup.hp.com> wrote in message
>news:988757459.310084@hpvablab.cup.hp.com...
>> toaster <toaster@nomail.org> writes:
>> perl -e'print sprintf("0x%x", unpack("L", pack("f", 42.1234)))'
>
>Not bad, but I do have to ask: why are we saying print sprintf?
Good point -- it's just because I'm used to the following idiom ...
$result = sprintf(...);
Rich
--
Rich Rauenzahn ----------+xrrauenza@cup.hp.comx+ Hewlett-Packard Company
Technical Consultant | I speak for me, | 19055 Pruneridge Ave.
Development Alliances Lab| *not* HP | MS 46TU2
ESPD / E-Serv. Partner Division +--------------+---- Cupertino, CA 95014
------------------------------
Date: Wed, 2 May 2001 15:45:32 -0700
From: "Brandon Thornburg" <centreman_19@NOSPAMyahoo.com>
Subject: Re: Recursing a directory tree
Message-Id: <9cq2vh$klg$1@fremont.ohsu.edu>
Sigh. Has it gotten to this point? In our effort to find every instance to
say RTFM, we're actually shilling for book purchases?
You even included the ISBN number. I realize there's lots of people who
don't make any effort to read freely available online docs but I don't think
we should try to sell books to people coming to newsgroups with
questions...otherwise why not just have an autoresponder that sends anyone
who posts a message to usenet directly to http://www.amazon.com.
Now, if you don't want to give him simple code for recursing, that's fine.
But at least educate him in how to find the docs he needs, instead of trying
to sell him a book.
"Robert Fonda" <rlf@proimages.net> wrote in message
news:3AF04993.DD7F597@proimages.net...
> Arun Horne wrote:
> >
> > Does anyone have some simple code to recurse a directory tree please??
Best
> > regards Arun Horne.
> >
> > Replace NOSPAM with @ in address to reply
>
> Go pick up a copy of the Perl Cookbook from O'reilly & Associates. ISBN:
> 1-56592-243-3. It has a nice example of exactly what you want to do! Not
> to mention a bazillion other good examples.
>
> r.f
------------------------------
Date: 2 May 2001 23:41:19 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Recursing a directory tree
Message-Id: <9cq5uv$s7m$1@mamenchi.zrz.TU-Berlin.DE>
According to Brandon Thornburg <centreman_19@NOSPAMyahoo.com>:
By top-posting you severely limit the number of your readership.
This sounds like something you want to have heard.
> Sigh. Has it gotten to this point? In our effort to find every instance to
> say RTFM, we're actually shilling for book purchases?
Yikes! A book suggestion on Usenet!
> You even included the ISBN number. I realize there's lots of people who
> don't make any effort to read freely available online docs but I don't think
> we should try to sell books to people coming to newsgroups with
> questions...otherwise why not just have an autoresponder that sends anyone
> who posts a message to usenet directly to http://www.amazon.com.
There are good books about Perl, and there are crappy books. Advice
on what books to buy is high in demand among Perl novices. PCB is
one of the good ones, that's why it deserves recommendation.
> Now, if you don't want to give him simple code for recursing, that's fine.
There is no simple code for recursing down a directory structure,
and details depend on the operating system and the OP's particular
needs. Some of the pitfalls involve the current directory, OS-dependent
expansion of path names, and re-use of directory-handles, just to name
a few. Far better to point the poster to a source that discusses these
problems thoroughly than to improvise a solution that may or may not work.
> But at least educate him in how to find the docs he needs, instead of trying
> to sell him a book.
O'Reilly is known for the fact that the code from their books is
available on their web site. I'd be surprised if PCB was an exception.
Books can also be borrowed; if you know what you're looking for you
can even go to a book store and look it up.
I'm all for keeping commercialism out of Usenet, but you're, uh...
what's it they say about the baby and the bath water?
Anno
[jeopardectomy]
------------------------------
Date: Thu, 03 May 2001 02:19:05 +0200
From: Abe Timmerman <abe@ztreet.demon.nl>
Subject: Re: RegExp Teaser
Message-Id: <r571ftsi1qm4h83g1k9uhkd54b1i7bgb8c@4ax.com>
On Mon, 30 Apr 2001 19:02:36 +0100, "S Warhurst"
<bigusAT@btinternetDOT.com> wrote:
> Hi
Hi,
...
> However, I haven't been able to suss this one out..
>
> I have a text file containing the following kind of text (a listserv catalog
> file in case anyone recognises it):
[ see __DATA__ section ]
> Now, I converted the array holding the file contents into a scalar & added
> the "-#-" in order to make the regexp easier.
I'm not sure in what order you do this. If you have the code that
inserts these '-#-' things, you _already_ know where each block starts
(and ends), why do you need to redo all the work?
If you read the file into an array and then convert it to a scalar, you
might want to consider 'slurp mode', to read the file contents directly
into a scalar.
...
> What it's doing is it's including the ending "-#-" delimiter thingy. How can
> I get it not to include the end "-#-".. (the character before that could be
> any character).
As already stated, positive look-ahead ( see perlre.pod ). I 'strip' the
leading '-#-' by not including it in the capturing parentheses.
#!/usr/bin/perl -w
use strict;
my $content = do { local $/; <DATA> };
print "Found: $1\n" while $content =~ /^-#-(.+?)(?=-#-)/msg;
__DATA__
* preamble
*
* more preamble
*
-#-file1.txt
* File 1 description
-#-file2.htm
* File 2 description
* some file descriptions have more than one line
-#-file3.xls
* File 3 description-#-
--
Good luck, Abe
Amsterdam Perl Mongers http://amsterdam.pm.org
perl -wle '$_=q@Just\@another\@Perl\@hacker@;print qq@\@{[split/\@/]}@'
------------------------------
Date: 2 May 2001 22:24:34 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Removing blank lines from end of data
Message-Id: <9cq1f2$pfa$1@mamenchi.zrz.TU-Berlin.DE>
According to Dan <nospam@newsranger.com>:
> I have code that will remove ALL the blank lines from data with this regular
> expression:
>
> $page =~ s/\s{2,}/\n/gs;
Don't try this with old-fashioned typists like myself, who use
two spaces to separate sentences (in a monospace font).
Your pattern will turn every sequence of two or more *whitespace*
characters into a newline. I doubt you want that. Why use \s on
the left side when \n is good enough on the right side?
Also, you don't need the /s modifier, since there is no "." in
your pattern.
s/\n{2,}/\n/g
> But I would only like to remove blank lines at the end of the data. How would I
> do that?
You would anchor the pattern to the end of the string ($) and remove
the now-superfluous /g:
s/\n{2,}$/\n/
Anno
------------------------------
Date: Wed, 02 May 2001 22:45:57 GMT
From: fxn@isoco.com (F. Xavier Noria)
Subject: Re: Removing blank lines from end of data
Message-Id: <3af0897e.1238531@news.iddeo.es>
On Wed, 02 May 2001 21:25:57 GMT, Dan <nospam@newsranger.com> wrote:
: I would only like to remove blank lines at the end of the data. How would I
: do that?
This removes the trailing whitespace (which includes those lines):
$page =~ s/\s*$//;
-- fxn
------------------------------
Date: 02 May 2001 22:23:12 +0000
From: Jon Ericson <Jonathan.L.Ericson@jpl.nasa.gov>
Subject: Re: Removing blank lines from end of data
Message-Id: <86vgnjl7an.fsf@jon_ericson.jpl.nasa.gov>
Dan <nospam@newsranger.com> writes:
> I have code that will remove ALL the blank lines from data with this regular
> expression:
>
> $page =~ s/\s{2,}/\n/gs;
Actually what it does is globally replace 2 or more white space
characters in a row with a newline. Note that since there are no `.'
characters in the regex, the `/s' modifier is superfluous. I assume
you meant \n{2,}.
> But I would only like to remove blank lines at the end of the data.
> How would I do that?
Simple. Anchor the pattern:
$page =~ s/\n{2,}$/\n/g;
Take a look at perlre and perlretut.
Jon
------------------------------
Date: Thu, 03 May 2001 02:21:14 GMT
From: "Bruno Pagis" <brunopagis@earthlink.net>
Subject: Running perl script on the DOS prompt (Windows)
Message-Id: <ug3I6.3386$Cq3.321620@newsread1.prod.itd.earthlink.net>
Does anybody has a replacement for the hugly MS-DOS windows that comes by
default with Microsoft windows (I'm talking of this window with a black
background, no scrollbar, and so on ...).
Is there an alternative to access the DOS prompt (something similar to an
xterm).
Thanks. BRUNO.
------------------------------
Date: Thu, 3 May 2001 10:39:31 +0800
From: "Just in" <justin.devanandan.allegakoen@intel.com>
Subject: Re: Running perl script on the DOS prompt (Windows)
Message-Id: <9cqgd6$4b6@news.or.intel.com>
Hugly it is, but you can change the buffer size and colours on the
properties menu
when you right click on the title bar of the DOS prompt
Happy tuning!
"Bruno Pagis" <brunopagis@earthlink.net> wrote in message
news:ug3I6.3386$Cq3.321620@newsread1.prod.itd.earthlink.net...
> Does anybody has a replacement for the hugly MS-DOS windows that comes by
> default with Microsoft windows (I'm talking of this window with a black
> background, no scrollbar, and so on ...).
> Is there an alternative to access the DOS prompt (something similar to an
> xterm).
>
> Thanks. BRUNO.
>
>
------------------------------
Date: 2 May 2001 23:28:44 GMT
From: Billy Chambless <billy@localhost.net>
Subject: Re: Should Perl be first?
Message-Id: <9cq57c$6mu$1@news.datasync.com>
[ top posting repaired ]
In article <9cof60$8es$1@merki.connect.com.au>,
Tom Beer <tom.beer@btfinancialgroup.spamfilter.com> wrote:
> "Billy Chambless" <billy@localhost.net> wrote in message
> news:9cnkka$gjq$1@news.datasync.com...
>> Although a person can certainly learn one language and start getting
>> real work done, learning several languages is part of the process of
>> learning the profound truths of programming that are needed to make a
>> Really Great Programmer.
>While I agree, I don't think IT recruitment agencies really see it that way.
It depends on the agency.
>What they want to hear is an interview is "yep, 10 years Perl experience",
>rather than "no Perl experience, but I know a heap of other languages!!".
Well... let's create some pathological cases. If I interviewed someone who
claimed 10 years experience, but only knew one language, I'd probably
not be very interested. OTOH, given a person who had learned five languages
well in 10 years, but didn't happen to know Visual COBOL++ for Palmpilot
(that being what the PHB told me we needed), I might be inclined to take
a chance with that person.
Especially the way technology is moving these days, proven ability to
learn a new language (or whatever) is pretty important.
From personal experience, my last three major projects have each required
me to learn a new language. YMMV.
>You might still get the job, but it will be harder.
But now we're discussing credentialism (or marketability) versus
being able to do something well.
You do have a good point, but to some extent I kind of figure that if a
company has stupid hiring criteria, I don't want to work there anyway. :)
------------------------------
Date: Thu, 03 May 2001 00:11:58 GMT
From: mjd@plover.com (Mark Jason Dominus)
Subject: Re: Should Perl be first?
Message-Id: <3af0a24a.546a$227@news.op.net>
In article <9cof60$8es$1@merki.connect.com.au>,
Tom Beer <tom.beer@btfinancialgroup.spamfilter.com> wrote:
>While I agree, I don't think IT recruitment agencies really see it that way.
>
>What they want to hear is an interview is "yep, 10 years Perl experience",
>rather than "no Perl experience, but I know a heap of other languages!!".
"Well, for the past ten years I've been employed to look up things in
a dictionary that begin with T."
"Sorry, we need someone with three years of solid experience looking
things up that begin with M and R. But we'll call you if anything
opens up."
--
@P=split//,".URRUU\c8R";@d=split//,"\nrekcah xinU / lreP rehtona tsuJ";sub p{
@p{"r$p","u$p"}=(P,P);pipe"r$p","u$p";++$p;($q*=2)+=$f=!fork;map{$P=$P[$f^ord
($p{$_})&6];$p{$_}=/ ^$P/ix?$P:close$_}keys%p}p;p;p;p;p;map{$p{$_}=~/^[P.]/&&
close$_}%p;wait until$?;map{/^r/&&<$_>}%p;$_=$d[$q];sleep rand(2)if/\S/;print
------------------------------
Date: Thu, 3 May 2001 12:41:07 +1000
From: "Tom Beer" <tom.beer@btfinancialgroup.spamfilter.com>
Subject: Re: Simple newbie performance question
Message-Id: <9cqggb$9mn$1@merki.connect.com.au>
"Godzilla!" <godzilla@stomp.stomp.tokyo> wrote in message
news:3AECD984.C58A951D@stomp.stomp.tokyo...
>
>
> (snipped)
>
>
> > } Yes, you are missing something. You are missing a reminder
> > } you are new to Perl as previously stated, by you. I question
> > } if you are in a position to present a logical debate regarding
> > } a comparison and contrast of array looping and while looping.
>
> > I said that I was new to Perl, but that I was not new to programming.
>
> Clearly you are not new to posting troll articles, as well.
>
> * demure smile *
>
> Godzilla!
plonk!!
------------------------------
Date: Wed, 02 May 2001 21:18:12 -0400
From: Alex <alex2@andrew.cmu.edu>
Subject: test
Message-Id: <995814295.988838292@alex2>
------------------------------
Date: Wed, 02 May 2001 20:33:53 -0400
From: Pete <petethsc@mindspring.com>
Subject: Unix Process Test
Message-Id: <3AF0A771.C0D20B68@mindspring.com>
I am converting a ksh script that grep's a ps listing for a particular
process and states whether the process is up or not ;
$item = 0;
$xterm= "xterm";
open(PS, "ps -e|grep $xterm|") or die "Can't run program: $!\n";
while(<PS>) {
$output = $_;
{$item = 1 if /$xterm/} ;
print "xterm running\n" if $item == 1;
print "xterm not running\n" if $item != 1;
close(README);
}
I only need to know that one of the particular processes is running. The
above gives me a result for all the processes that match $xterm.
First of all does anyone know of a tutorial on this subject and secondly
does anyone have a solution ?.
Thanks
Pete
------------------------------
Date: Thu, 03 May 2001 02:17:53 GMT
From: John W Krahn <krahnj@acm.org>
Subject: Re: Unix Process Test
Message-Id: <3AF0BFEA.374A4A8A@acm.org>
Pete wrote:
>
> I am converting a ksh script that grep's a ps listing for a particular
> process and states whether the process is up or not ;
>
> $item = 0;
> $xterm= "xterm";
> open(PS, "ps -e|grep $xterm|") or die "Can't run program: $!\n";
> while(<PS>) {
> $output = $_;
> {$item = 1 if /$xterm/} ;
> print "xterm running\n" if $item == 1;
> print "xterm not running\n" if $item != 1;
> close(README);
> }
my @xterms = grep /\bxterm\b/, `ps -e`;
if ( @xterms ) {
print scalar( @xterms ), " xterms running\n";
}
else {
print "xterm not running\n";
}
> I only need to know that one of the particular processes is running. The
> above gives me a result for all the processes that match $xterm.
How do you differenciate this particular process from all the others?
> First of all does anyone know of a tutorial on this subject and secondly
> does anyone have a solution ?.
Define "this subject"
John
------------------------------
Date: Wed, 02 May 2001 23:37:01 GMT
From: "Eric" <mail@NOSPAMericmarques.net>
Subject: Uploading to http sites
Message-Id: <xS0I6.30181$PF4.54957@news.iol.ie>
this has been puzzling me all day
i am trying to recreate the browsers uploading function so i can upload to a
website that uses this function
i used a monitoring prog to see what the browser sends to upload the file
however when i type these commands in telnet to test them before using perl
script
it doesnt work and cgi-lib.pl gives this error
cgi-lib: reached end of input while seeking end of headers. Format of CGI
input is wrong.
Please tell me whats wrong with these headers that its not accepted
the headers are:
POST http://194.165.160.74/test/debug.cgi HTTP/1.0
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg,
application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword,
*/*
Referer: http://194.165.160.74/test/upload.html
Accept-Language: en-ie
Content-Type: multipart/form-data;
boundary=---------------------------7d124e29258
Proxy-Connection: Keep-Alive
User-Agent: Mozilla/4.0 (compatible; MSIE 5.5; Windows 98; Win 9x 4.90)
Host: 194.165.160.74
Content-Length: 725
Pragma: no-cache
-----------------------------7d124e29258
Content-Disposition: form-data; name="wl"
2
-----------------------------7d124e29258
Content-Disposition: form-data; name="file-to-upload-01";
filename="C:\WINDOWS\Desktop\test.txt"
Content-Type: application/octet-stream
test file
-----------------------------7d124e29258--
------------------------------
Date: Thu, 03 May 2001 03:21:26 GMT
From: "Rob" <"relaxedrob@optushome.com.au">
Subject: Re: Windows Komodo users get input on debug?
Message-Id: <W84I6.1863$76.7814@news1.rdc1.nsw.optushome.com.au>
Hi Arek!
The bug is that even the console option doesn't work for Windows, so you
can't send input to your scripts while debugging (which is the only way
Komodo has to run a script).
Rob
"Arek P" <Arek@nospam.tv> wrote in message
news:9cp8ib$1gpb$1@earth.superlink.net...
> On Tue, 01 May 2001 03:09:53 GMT, "Rob"
> <"relaxedrob@optushome.com.au"> wrote:
>
> I doubt that this is considered a bug; If You look at the help docs
> that came with Komodo it clearly states that in order to be able to
> send input You have to use the console window; so when U try to run
> debugger, check off the 'Debug in separate console' option and then U
> will be albe to do it. I know that the Komodo debuggers' output tab
> will show the prompt with the cursor waiting for Your input, which
> would appear to suppose to work, but it does not, You cannot type
> anything and it just sits there. It seems to me that output win is
> non-input scripts...at least this is what I got out of the help
> pages...
> ArekP
>
> >Hi all!
> >
> >I am interested to hear from anyone using Komodo on Windows who is able
to
> >send input to their perl scripts through the debugger. This feature does
not
> >seem to work on my machine. I have submitted a bug report but am after
> >anyone else who has had the same..
> >
> >Rob
> >
> >
>
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
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.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 825
**************************************