[13432] in Perl-Users-Digest
Perl-Users Digest, Issue: 842 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Sep 18 13:07:18 1999
Date: Sat, 18 Sep 1999 10:05:08 -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: <937674308-v9-i842@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Sat, 18 Sep 1999 Volume: 9 Number: 842
Today's topics:
Re: backref problem <ltl@rgsun40.viasystems.com>
Re: CGI in PERL (Kragen Sitaker)
Re: CGI in PERL (Larry Rosler)
Re: CONTEST: Range Searching <tolkin@mediaone.net>
Converting time() to real date <2bunnyhop@home.com>
Re: Converting time() to real date <jkline@one.net>
Re: Does Larry Wall ever post here? (Kragen Sitaker)
Re: Does Larry Wall ever post here? <rick.delaney@home.com>
Re: Does Larry Wall ever post here? <tchrist@mox.perl.com>
Re: Does Larry Wall ever post here? (Matthew Bafford)
Re: Help! (writing cgi/pearl/sendmail program) <jkline@one.net>
Re: Help! (writing cgi/pearl/sendmail program) (Bill Moseley)
Re: Help! (writing cgi/pearl/sendmail program) <puyrebelNOSPAMTHANKS@prodigy.net>
I could use perldoc perlipctut (Bill Moseley)
Re: I could use perldoc perlipctut (Kragen Sitaker)
Re: I could use perldoc perlipctut <tchrist@mox.perl.com>
Re: List files in a dir <ltl@rgsun40.viasystems.com>
Re: making 'find' follow soft links (Kragen Sitaker)
Re: perl return value to a perl script (Kragen Sitaker)
Re: Sorting on a string, by value. (Larry Rosler)
Re: transform / in \/ <jkline@one.net>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 18 Sep 1999 16:28:23 GMT
From: lt lindley <ltl@rgsun40.viasystems.com>
Subject: Re: backref problem
Message-Id: <7s0ej7$jme$1@rguxd.viasystems.com>
Eric Bohlman <ebohlman@netcom.com> wrote:
:>Eric Niebler (ericne@microsoft.com) wrote:
:>: $foo = 'foobar';
:>: if( $foo =~ m/((foo)|bar)+/ ) {
:>: print "0=$&\n";
:>: print "1=$1\n";
:>: print "2=$2\n";
:>: }
:>:
:>: It prints out:
:>: 0=foobar
:>: 1=bar
:>: 2=foo
:>:
:>: Why is $2 "foo"? Shouldn't it be empty? The last time ((foo)|bar) matches,
:>: it matches "bar", so the (foo) group didn't match anything. Doesn't that
:>: mean $2 should be empty?
Written like this:
print "0=$&\n1=$1\n2=$2\n" while ($foo =~ /((foo)|bar)/g);
You get:
0=foo
1=foo
2=foo
0=bar
1=bar
2=
Does that match your intention Mr. Niebler?
:>Nope. Regex memory variables are *not* altered by unsuccessful matches.
But this is a successful match. In this case $1 and $2 are set
during the same match. The concept of "the last time ((foo)|bar)
matches" is misleading because it is "((foo|bar)+" and it is only one
successful match, not two. There is only one "time" of the regexp
evaluation. It just matched multiple substrings at the same time.
Hmmm. That doesn't sound very satisfying. Maybe someone else will
step in with a clearer explanation.
--
// Lee.Lindley /// Programmer shortage? What programmer shortage?
// @bigfoot.com /// Only *cheap* programmers are in short supply.
//////////////////// 50 cent beers are in short supply too.
------------------------------
Date: Sat, 18 Sep 1999 15:27:21 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: CGI in PERL
Message-Id: <tbOE3.18408$N77.1383089@typ11.nn.bcandid.com>
In article <7rvgmf$lrr$1@nnrp1.deja.com>,
John Moreno <jmorneo@my-deja.com> wrote:
>BASIC = Beginner's All-Purpose Symbolic Instruction Code
According to rumor, this acronym expansion was invented considerably
later than the language itself.
BTW, COBOL really is spelled with all caps. So is FORTRAN. Indeed,
most languages from the 1950-1970 era were.
--
<kragen@pobox.com> Kragen Sitaker <http://www.pobox.com/~kragen/>
Fri Sep 17 1999
52 days until the Internet stock bubble bursts on Monday, 1999-11-08.
<URL:http://www.pobox.com/~kragen/bubble.html>
------------------------------
Date: Sat, 18 Sep 1999 09:20:53 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: CGI in PERL
Message-Id: <MPG.124d5bb5698bc22e989f9c@nntp.hpl.hp.com>
In article <tbOE3.18408$N77.1383089@typ11.nn.bcandid.com> on Sat, 18 Sep
1999 15:27:21 GMT, Kragen Sitaker <kragen@dnaco.net> says...
> In article <7rvgmf$lrr$1@nnrp1.deja.com>,
> John Moreno <jmorneo@my-deja.com> wrote:
> >BASIC = Beginner's All-Purpose Symbolic Instruction Code
>
> According to rumor, this acronym expansion was invented considerably
> later than the language itself.
Search this newsgroup in Deja.com for a discussion of retro-acronyms in
regard to Perl itself.
> BTW, COBOL really is spelled with all caps. So is FORTRAN. Indeed,
> most languages from the 1950-1970 era were.
Were, but no longer are, if they still are widely used.
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Sat, 18 Sep 1999 11:29:11 -0400
From: Steven Tolkin <tolkin@mediaone.net>
Subject: Re: CONTEST: Range Searching
Message-Id: <37E3AFC7.9D9BB420@mediaone.net>
The contest is fun, produces a lot of creative output, and solves a real
need (an improved version of the old cgrep (context grep) from the first
Camel that I still use). But I am concerned that it still seems to
emphasize the mentality of cleverness (which seems to cause obscurity).
Tom Christiansen (who will get this as email too) wrote:
....
> Solutions will be judged upon these overall criteria:
....
> Subjective:
>
> * conciseness: keep it short. no frills. just a few lines.
> * clarity: is this understandable to a native perl speaker?
> * idiom: does this look like natural perl? does it use cool
> perl features absent in other languages?
> * creativity: is your solution cleverly different from those
> of others?
I suggest that these subjective criteria miss a few that are more
important:
* extensibility: How easy is it to add functionality, or add robustness.
Adding robustness might include complete error checking of the options,
e.g for non-negative integers, warning if the file does not seem to be
Text, etc. Extensibility in this case might consist of accepting a list
of patterns to match and having each have an associated before and after
count. Or simply accepting many of the grep options, e.g. -i for case
insensitive match, or -v for inverting the sense of the match, etc.
* reusability: Does the code reuse existing modules? Presumably these
are "battle tested". Does the code contribute a new module that could
be reused by others?
On the topic of clarity I would like to suggest that there are ways to
assess this in a quasi-objective manner. The technique of bebugging
(sic) consists of deliberately distorting the program by adding,
removing, or moving a syntactic construct: character, token, line, etc.
and then testing how long it takes a programmer to make a repair.
This is a surrogate measure for the main pragmatic goal of clarity:
increasing the ability of competent Perl programmer to find and
correctly fix a bug, or add a feature.
A main benefit of using idioms is that it can sometimes contribute to
clarity. Idioms can also contribute to performance. But too often
idioms cause perplexity.
What am I belaboring the obvious? Because I believe the Perl community
must try hard to overcome Perl's reputation of being hard to
understand. APL is the protoype of a language that encouraged
"one-liners" and look at its fate. (OK, the use of a "creative"
character set also played a role.)
I love Perl; it is the highest level language available for solving
practical programming problems, is truly portable, etc. But "image"
*is* important in the real world. Perl is not being used in some
projects due to its reputation. That is a fact. We should be
emphasizing Perl's suitability for quickly writing programs
that are correct and efficient.
Hopefully helpfully yours,
Steve
--
Steven Tolkin tolkin@mediaone.net work: steve.tolkin@fmr.com
Fidelity Investments 82 Devonshire St. R24D Boston MA 02109
617-563-0516
There is nothing so practical as a good theory. Comments are by me,
not Fidelity Investments, its subsidiaries or affiliates.
------------------------------
Date: Sat, 18 Sep 1999 15:10:28 GMT
From: "Craig Vincent" <2bunnyhop@home.com>
Subject: Converting time() to real date
Message-Id: <EXNE3.42790$kL1.516589@news2.rdc1.on.home.com>
I'm sure this is an incredibly easy function to do...but how do you convert
the return of a time() function to be the actual corresponding date/time?
Craig Vincent
------------------------------
Date: Sat, 18 Sep 1999 11:29:32 -0400
From: Joe Kline <jkline@one.net>
Subject: Re: Converting time() to real date
Message-Id: <37E3AFDC.2FB7D25D@one.net>
Craig Vincent wrote:
>
> I'm sure this is an incredibly easy function to do...but how do you convert
> the return of a time() function to be the actual corresponding date/time?
Take a gander at the documentation provided in your installation of
perl for the time() function. You should be able to do 'perldoc -f
time' from an available command-line. If you are a PoB and have an
ActiveState installation try Start->Programs->ActivePerl->Online
Documentation, then search perlfunc for time.
If you need further spoon feeding look up the documentation for
localtime() and/or gmtime(), depending upon your needs.
If you require further spoon feeding, I refuse to give it.
joe
-----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
http://www.newsfeeds.com The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including Dedicated Binaries Servers ==-----
------------------------------
Date: Sat, 18 Sep 1999 16:04:27 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: Does Larry Wall ever post here?
Message-Id: <fKOE3.18506$N77.1387495@typ11.nn.bcandid.com>
In article <7s093m$4fv$1@nnrp1.deja.com>, <makau@multimania.com> wrote:
>I have seen Randal and Tom's posts in this newsgroup but never Larry's.
>
>Does he ever post here? (just curious :O)
No. He hasn't posted here in quite a while. I don't think he even
reads news anymore. Too little signal?
Tom has something on his web site about why he is tempted to abandon
Usenet himself, a parable about a town suddenly swamped with newcomers
who want food but refuse to work for it.
--
<kragen@pobox.com> Kragen Sitaker <http://www.pobox.com/~kragen/>
Fri Sep 17 1999
52 days until the Internet stock bubble bursts on Monday, 1999-11-08.
<URL:http://www.pobox.com/~kragen/bubble.html>
------------------------------
Date: Sat, 18 Sep 1999 16:13:37 GMT
From: Rick Delaney <rick.delaney@home.com>
Subject: Re: Does Larry Wall ever post here?
Message-Id: <37E3BA29.E28CCEF9@home.com>
[posted & mailed]
makau@multimania.com wrote:
>
> Does he ever post here? (just curious :O)
>
> Sent via Deja.com http://www.deja.com/
^^^^^^^^^^^^^^^^^^^^
This is more than just a bad news client, you know.
--
Rick Delaney
rick.delaney@home.com
------------------------------
Date: 18 Sep 1999 10:21:19 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Does Larry Wall ever post here?
Message-Id: <37e3bbff@cs.colorado.edu>
[courtesy cc of this posting mailed to cited author]
In comp.lang.perl.misc, makau@multimania.com writes:
:I have seen Randal and Tom's posts in this newsgroup but never Larry's.
:
:Does he ever post here? (just curious :O)
Slightly reformatted:
From: Larry Wall <larry@wall.org>
Subject: Re: Perl's underlying implementation of Arrays - Low Priority
Newsgroups: comp.lang.perl.misc
Date: Wed, 08 Sep 1999 08:51:22 GMT
Organization: Posted via Supernews, http://www.supernews.com
Message-ID: <19990908.8512200@kiev.wall.org>
References: <936408311.376813@diddley.primus.com.au> <hG_z3.154$lT.757@news.rdc1.ct.home.com>
X-Newsreader: Mozilla/3.0 (compatible; StarOffice/5.1; Solaris Sparc)
Lines: 38
On 9/3/99, 5:34:05 PM, Dan Sugalski <dan@tuatha.sidhe.org> wrote:
> So basically if you unshift on the beginning or push on the end you
> can potentially end up shifting memory, and if you splice in the
> middle you definitely will.
Yes, though it looks to see which end of the array it's closer to,
and shifts as little as possible. (Same goes for substr() within
a string.)
> With either one you may trigger a realloc.
>
> If you think this is inefficient, it actually isn't. It works very
> well for the common usage of arrays, which is the way you want
> it. (The common things should be fast. Uncommon or messy things can
> be slower)
Also, one should bear in mind that even if you have to shift some
memory, you're not actually moving the data, just some pointers
to the data, so it's quite efficient. In a sense, the longer the
strings you're processing, the more efficient it is, relative to
how much data you're processing.
On the other hand, this is why we don't view strings as arrays of
characters in Perl. The overhead to store each character would
be unacceptable in that case. Much easier to move the characters
themselves than pointers to them.
Larry
--
Nuclear war doesn't prove who's Right, just who's Left (ABC news 10/13/87)
------------------------------
Date: Sat, 18 Sep 1999 16:41:21 GMT
From: *@dragons.duesouth.net (Matthew Bafford)
Subject: Re: Does Larry Wall ever post here?
Message-Id: <slrn7u7f4e.1i2.*@dragons.duesouth.net>
Kragen Sitaker), thinking with his hands, posted the following to
comp.lang.perl.misc:
: No. He hasn't posted here in quite a while. I don't think he even
: reads news anymore. Too little signal?
Actually, he posted a few weeks ago.
It seems he does some careful searching of the newsgroups, or maybe
someone lets him know about threads that would be of interest to him.
In either case, he appears from time to time, participates in a thread,
and then dissapears.
--Matthew
------------------------------
Date: Sat, 18 Sep 1999 11:24:47 -0400
From: Joe Kline <jkline@one.net>
Subject: Re: Help! (writing cgi/pearl/sendmail program)
Message-Id: <37E3AEBF.59BF19B8@one.net>
raynew@my-deja.com wrote:
>
> I also need help with writing a cgi/pearl/sendmail program
^[1] ^[2] ^[3]
[1] a protocol, generally frowned upon to ask such questions here.
Try: comp.infosystems.www.authoring.cgi
[2] ??? Maybe you're thinking of Perl - the language or perl - the
implementation of Perl
[3] interesting/cool bit o' software (I like to use Net::SMTP)
joe
-----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
http://www.newsfeeds.com The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including Dedicated Binaries Servers ==-----
------------------------------
Date: Sat, 18 Sep 1999 08:17:24 -0700
From: moseley@best.com (Bill Moseley)
Subject: Re: Help! (writing cgi/pearl/sendmail program)
Message-Id: <MPG.124d4cdeee93b929989754@nntp1.ba.best.com>
raynew@my-deja.com (raynew@my-deja.com) seems to say...
> I also need help with writing a cgi/pearl/sendmail program
If you are going to crosspost, do so. Don't send duplicate messages to
different groups.
--
Bill Moseley mailto:moseley@best.com
pls note the one line sig, not counting this one.
------------------------------
Date: Sat, 18 Sep 1999 11:48:20 -0500
From: Ken Robbins <puyrebelNOSPAMTHANKS@prodigy.net>
Subject: Re: Help! (writing cgi/pearl/sendmail program)
Message-Id: <37E3C254.7B872310@prodigy.net>
raynew@my-deja.com wrote:
> [...]
> BUT
>
> Reply-To:
>
> and
>
> From:
>
> change to myname@mydomain.com
> [...]
I don't know about anyone else, but doesn't that sound like he is going
to send spam?
--
Ken Robbins
Remove NOSPAMTHANKS to reply by e-mail.
------------------------------
Date: Sat, 18 Sep 1999 08:11:43 -0700
From: moseley@best.com (Bill Moseley)
Subject: I could use perldoc perlipctut
Message-Id: <MPG.124d4b8997be86fc989753@nntp1.ba.best.com>
A few IPC questions:
1) Could someone give an example on how to spawn off a few children,
wait for them to all finish and collect all the data back? I'm unclear
on how to manage a bunch of kids all at once. The goal is to split up
some work.
2) If I want a child to operate on some complex data from the parent
what options do I have to send the data back to the parent? That is,
say I want a child to operate on an array of hashes that the parent
created -- do something TO the data in the hashes, and then make that
available to the parent. Would I need to strinify (Data::Dumper) and
pass back via the child's file handle?
Thanks for your time,
--
Bill Moseley mailto:moseley@best.com
pls note the one line sig, not counting this one.
------------------------------
Date: Sat, 18 Sep 1999 16:06:56 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: I could use perldoc perlipctut
Message-Id: <AMOE3.18513$N77.1387885@typ11.nn.bcandid.com>
In article <MPG.124d4b8997be86fc989753@nntp1.ba.best.com>,
Bill Moseley <moseley@best.com> wrote:
>1) Could someone give an example on how to spawn off a few children,
>wait for them to all finish and collect all the data back? I'm unclear
>on how to manage a bunch of kids all at once. The goal is to split up
>some work.
It's doable; I don't have an example lying around. You can use waitpid
to check for zombie children, reap them, and return their pids.
It won't be any faster unless you're on MOSIX (www.mosix.cs.huji.ac.il)
or an SMP.
>2) If I want a child to operate on some complex data from the parent
>what options do I have to send the data back to the parent? That is,
>say I want a child to operate on an array of hashes that the parent
>created -- do something TO the data in the hashes, and then make that
>available to the parent. Would I need to strinify (Data::Dumper) and
>pass back via the child's file handle?
Yes.
--
<kragen@pobox.com> Kragen Sitaker <http://www.pobox.com/~kragen/>
Fri Sep 17 1999
52 days until the Internet stock bubble bursts on Monday, 1999-11-08.
<URL:http://www.pobox.com/~kragen/bubble.html>
------------------------------
Date: 18 Sep 1999 10:23:40 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: I could use perldoc perlipctut
Message-Id: <37e3bc8c@cs.colorado.edu>
[courtesy cc of this posting mailed to cited author]
In comp.lang.perl.misc,
moseley@best.com (Bill Moseley) writes:
:A few IPC questions:
:
:1) Could someone give an example on how to spawn off a few children,
:wait for them to all finish and collect all the data back? I'm unclear
:on how to manage a bunch of kids all at once. The goal is to split up
:some work.
Here's a demo from my class on Multitasking in Perl:
#!/usr/bin/perl -w
# process pool demo
use strict;
$| = 1; # fork can really make for stdio surprises
my $TOTAL = 100;
my $CONCUR_MAX = 10;
my $FORK_RETRIES = 5;
my $RETRY_SLEEP = 5;
my $DAWDLE = 10; # kid spins jets for 1+rand this
my %Launched = ();
run_queue();
exit;
##################
sub run_queue {
my $started = 0;
my $done = 0;
my $running = 0;
JOB:
while ($TOTAL > ($done+$running) || $running > 0) {
# sort by date in case pids wrap
print "Run queue: ", join(" ",
sort { $Launched{$a} <=> $Launched{$b} } keys %Launched),
"\n";
if ($running >= $CONCUR_MAX || $started >= $TOTAL) {
print "$$: waiting R=$running, S=$started D=$done\n";
my $child = wait;
die "REAPED WRONG CHILD: $child ($?)" unless $Launched{$child};
my $runtime = time() - $Launched{$child};
delete $Launched{$child};
print "Child $child has completed, after $runtime seconds\n";
print "Child $child exited " . ($? << 8) . "\n" if $?;
$done++;
--$running;
next JOB;
}
next if ($done+$running) >= $TOTAL;
my $tries = 0;
my $kid;
RETRY: {
$kid = fork();
unless (defined $kid) {
warn "$0 $$: cannot fork: $!";
if ($tries++ < $FORK_RETRIES) {
warn "$0 $$: sleep and retry\n";
sleep 5;
redo RETRY;
}
}
}
if ($kid) {
$running++;
$started++;
$Launched{ $kid } = time();
}
else {
run_job();
exit;
# NOT REACHED
}
}
}
sub run_job {
print "$$ is napping\n";
sleep(1 + int(rand($DAWDLE)));
print "$$ had a nice nap.\n";
}
:2) If I want a child to operate on some complex data from the parent
:what options do I have to send the data back to the parent? That is,
:say I want a child to operate on an array of hashes that the parent
:created -- do something TO the data in the hashes, and then make that
:available to the parent. Would I need to strinify (Data::Dumper) and
:pass back via the child's file handle?
Well, yes, that would be easy.
Here's another idea. It's from the Ram Book:
#!/usr/bin/perl
# sharetest - test shared variables across forks
use IPC::Shareable;
$handle = tie $buffer, 'IPC::Shareable', undef, { destroy => 1 };
$SIG{INT} = sub { die "$$ dying\n" };
for (1 .. 10) {
unless ($child = fork) { # i'm the child
die "cannot fork: $!" unless defined $child;
squabble();
exit;
}
push @kids, $child; # in case we care about their pids
}
while (1) {
print "Buffer is $buffer\n";
sleep 1;
}
die "Not reached";
sub squabble {
my $i = 0;
while (1) {
next if $buffer =~ /^$$\b/o;
$handle->shlock();
$i++;
$buffer = "$$ $i";
$handle->shunlock();
}
}
--tom
--
pos += screamnext[pos] /* does this goof up anywhere? */
--Larry Wall in util.c from the perl source code
------------------------------
Date: 18 Sep 1999 15:37:48 GMT
From: lt lindley <ltl@rgsun40.viasystems.com>
Subject: Re: List files in a dir
Message-Id: <7s0bkc$ivp$1@rguxd.viasystems.com>
Tom Christiansen <tchrist@mox.perl.com> wrote:
:> [courtesy cc of this posting mailed to cited author]
:>In comp.lang.perl.misc, lee.lindley@bigfoot.com writes:
:>:If this is truly a common idiom, please point me to additional
:>:reading material.
:>It is. And I shall.
:>--tom
:>% man perlfaq4
Ouch. I take some consolation with my embarrassment though.
"..fraught with quoting and readability problems.."
"..similar chicanery.."
"Here's a trick for interpolating.."
"This chicanery is also useful for.."
"Here's a trick for interpolating.."
"Or you can use the slightly sneaky.."
"shows the expansion trick:"
"When you absolutely must have interpolation, you need the
punctuation-riddled mess.."
:> Expanding backquotes (``) is particularly challenging,
:> because you would normally end up with spurious newlines. By
:> creating a braced block following the `@' within the `@{[]}'
:> anonymous array dereference, as we did in the last example,
:> you can create private variables.
:> Although these techniques work, it's almost always clearer and
:> easier on the reader to simply break your work up into several
:> steps or store everything in temporary variables.
Tom, you have written extensively on this technique, but you don't
seem to like it much. :-)
Given the volume of documentation devoted to this topic, I should
have recognized it immediately. Truly, I read every word of it at
one time or another. My memory seems to discard those bits that
I subconciously judge unworthy.
Your aesthetic preference may vary. (YAPMV?)
--
// Lee.Lindley /// Programmer shortage? What programmer shortage?
// @bigfoot.com /// Only *cheap* programmers are in short supply.
//////////////////// 50 cent beers are in short supply too.
------------------------------
Date: Sat, 18 Sep 1999 15:08:53 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: making 'find' follow soft links
Message-Id: <9WNE3.18396$N77.1380279@typ11.nn.bcandid.com>
In article <7rvsnq$1hl$1@gellyfish.btinternet.com>,
Jonathan Stowe <gellyfish@gellyfish.com> wrote:
>On 17 Sep 1999 22:02:22 GMT Peter Bismuti wrote:
>> Kragen Sitaker (kragen@dnaco.net) wrote:
>> : This is off-topic for a Perl newsgroup. The answers are: -follow, use
>> : GNU or SCO find.
>>
>> I'm referring to the Perl File::Find::find function, not the unix command
>> with the same name.
>
>There is a possibility that Kragen knew that - because he had read the
>File::Find manpage:
You flatter me too much. The truth is that I incorrectly chastised the
original poster because I didn't know File::Find existed. I'm sorry.
If I have time, I will fix File::Find to follow symlinks safely.
--
<kragen@pobox.com> Kragen Sitaker <http://www.pobox.com/~kragen/>
Fri Sep 17 1999
52 days until the Internet stock bubble bursts on Monday, 1999-11-08.
<URL:http://www.pobox.com/~kragen/bubble.html>
------------------------------
Date: Sat, 18 Sep 1999 16:34:43 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: perl return value to a perl script
Message-Id: <DaPE3.18620$N77.1390915@typ11.nn.bcandid.com>
In article <37E37A85.73BC71FC@algonet.se>,
Andreas Hagelberg <tlb@algonet.se> wrote:
>Well, system only returns the exit status of the executed program which
>is an integer containing exit-code and other stuff. To return strings
>you will need to use pipes.
Or `` or qx; perldoc perlop
--
<kragen@pobox.com> Kragen Sitaker <http://www.pobox.com/~kragen/>
Fri Sep 17 1999
52 days until the Internet stock bubble bursts on Monday, 1999-11-08.
<URL:http://www.pobox.com/~kragen/bubble.html>
------------------------------
Date: Sat, 18 Sep 1999 08:12:08 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Sorting on a string, by value.
Message-Id: <MPG.124d4ba7b3e66a0b989f9b@nntp.hpl.hp.com>
[Posted and a courtesy copy sent.]
In article <x7ogf0a2k5.fsf@home.sysarch.com> on 18 Sep 1999 07:20:41 -
0400, Uri Guttman <uri@sysarch.com> says...
> >>>>> "LR" == Larry Rosler <lr@hpl.hp.com> writes:
...
> LR> Oh, what the hell. Here's a go at it (tested; assumes all number fields
> LR> fit within a byte):
>
> i knew you would fall for this bait! and you make a possibly invalid
> assumption too. so there!
This is like the current thread among you, Bart Lateur and me, regarding
documented assumptions about the nature of the data. If this assumption
is in fact invalid, it can be fixed using 'n' packing for appropriate
subkeys, or 'N' packing if even two bytes won't hold the numbers, or 'd'
packing if things are really insane.
The point is to let the algorithm fit the data. Totalitarian approaches
are supererogatory.
> LR> @out =
> LR> map substr($_, 1 + rindex $_, "\0"),
> LR> sort
> LR> map {
> LR> my ( $num1, $str, $num2 ) = /([\d_]+)\.([a-z]+)(\d*)/i ;
> LR> pack 'C5 A* x A*' =>
> LR> split(/_/ => $num1), $num2 || 0, $str, $_
> LR> } @in ;
>
> i was hoping the poster would try to do this for himself.
Only in your dreams! At least this way the world will have seen yet
another well-written example of this magnificent technique. :-)
Note that use of the Schwartz on these six sortfields would have been
pretty ugly, to say nothing of slow and error-prone. (You got a bug in
with only three sortfields. :-)
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Sat, 18 Sep 1999 11:15:23 -0400
From: Joe Kline <jkline@one.net>
Subject: Re: transform / in \/
Message-Id: <37E3AC8B.FAE590C3@one.net>
Mattia wrote:
>
> I need to have a variable (let's say $foo) that points to a directory. I
> need to put this var both in string and in regular expression, so I need
> another var for regular expressions. In regular expression the / char must
> be preceded by the \ char. Let's say:
>
> #main var
> $foo = "/usr/bin/mattia";
>
> #var for regexp
> $regfoo="\/usr\/bin\/mattia";
>
> I would like get the $regfoo variable out of $fo, instead of typing it.
>
> I tried with tr///\// but it doesn't work.
Well, to add to Andreas's solution you could do the following in the
regex:
m/\Q$foo\E/;
This escapes any special regex characters. Take a look at 'perldoc
perlre'.
Your tr is wildly wrong as well:
tr///\//
^^^you're transposing nothing to nothing the remaing characters are
rather meaningless.
You'll need:
tr/\//\\\/;
This gives your regex ,"leaning-toothpick syndrome". That is, you need
to escape the special characters and choose different delimiters. To
make this more readable you might try:
tr!/!\\/!;
joe
-----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
http://www.newsfeeds.com The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including Dedicated Binaries Servers ==-----
------------------------------
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 V9 Issue 842
*************************************