[19966] in Perl-Users-Digest
Perl-Users Digest, Issue: 2161 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Nov 20 03:10:37 2001
Date: Tue, 20 Nov 2001 00:10:12 -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: <1006243812-v10-i2161@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Tue, 20 Nov 2001 Volume: 10 Number: 2161
Today's topics:
Re: Traversing directories (Randal L. Schwartz)
Re: Traversing directories <vze33mmh@verizon.net>
Re: Traversing directories (Tad McClellan)
Re: Traversing directories (Tad McClellan)
Re: Traversing directories (F. Xavier Noria)
Re: { in s///; ? <vze33mmh@verizon.net>
Re: { in s///; ? <uri@stemsystems.com>
Re: { in s///; ? (Tad McClellan)
Re: { in s///; ? <vze33mmh@verizon.net>
Re: { in s///; ? <uri@stemsystems.com>
Re: { in s///; ? (Tad McClellan)
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 19 Nov 2001 18:14:58 -0800
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: Traversing directories
Message-Id: <m166865gt9.fsf@halfdome.holdit.com>
>>>>> "sysop" == sysop <vze33mmh@verizon.net> writes:
sysop> This script will do what you want.
No, this script also follows symlinks erroneously.
DO NOT REINVENT DIRECTORY RECURSION (badly).
use File::Find
use File::Find
Please.
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
------------------------------
Date: Tue, 20 Nov 2001 02:37:45 GMT
From: sysop <vze33mmh@verizon.net>
Subject: Re: Traversing directories
Message-Id: <pan.2001.11.19.21.50.45.576530.2516@verizon.net>
Hmmm, me thinks you've had too much caffine recently... Perhaps I
should start any replies I post to this newsgroup with:
I am not the Oracle, nor should communication with me be held to be as
undeniably true as communication with god.
Sure, File::Find gives you all kinds of protection, allowing you to
follow symlinks without getting trapped in recursion. But I thought
maybe just a little snippet would do. I wasn't trying to reinvent
File::Find, I looked for FQPN at search.cpan.org, and scanned the File
Handle section, before bothering to write my own snippet. Nor was my
code supposed to be as universal as File::Find, it was simply to give
the guy the list of files in his directory. Do you blame me for trying
to help a fella out?
I also didn't know that there WERE symlinks in a Windows machine's
filesystem. (How does one go about creating them?) However, to keep
from following said symlinks you can, rather simply, check with -l,
like so:
...
if ((-d "$parent\\".$children[$index]) && (!(-l
"$parent\\".$children[$index]))){
...
Cheers
On Mon, 19 Nov 2001 21:14:58 -0500, Randal L. Schwartz wrote:
>>>>>> "sysop" == sysop <vze33mmh@verizon.net> writes:
>
> sysop> This script will do what you want.
>
> No, this script also follows symlinks erroneously.
>
> DO NOT REINVENT DIRECTORY RECURSION (badly).
>
> use File::Find
>
> use File::Find
>
> Please.
>
------------------------------
Date: Tue, 20 Nov 2001 04:27:00 GMT
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Traversing directories
Message-Id: <slrn9vjjui.huo.tadmc@tadmc26.august.net>
sysop <vze33mmh@verizon.net> wrote:
>On Mon, 19 Nov 2001 19:10:31 -0500, Rafal Konopka wrote:
>
>> I need a listing of all the *.htm files in an given directory and all
>> its subdirectories.
>This script will do what you want.
I don't think so. It does not list all the *.htm files.
[ snip 25 lines of code ]
Let's do it with a core module instead:
-----------------------------------
#!/usr/bin/perl -w
use strict;
use File::Find;
my $dir = '/home/httpd';
print "$_\n" foreach find_htm($dir);
sub find_htm {
my @htm;
find sub { push @htm, $File::Find::name if /\.htm$/ }, @_;
return @htm;
}
-----------------------------------
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Tue, 20 Nov 2001 05:04:44 GMT
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Traversing directories
Message-Id: <slrn9vjm5k.i6r.tadmc@tadmc26.august.net>
[ Please put your comments *following* the quoted text that you
are commenting on.
http://www.geocities.com/nnqweb/nquote.html
Text rearranged into actual chronology.
]
sysop <vze33mmh@verizon.net> wrote:
>On Mon, 19 Nov 2001 21:14:58 -0500, Randal L. Schwartz wrote:
>
>>>>>>> "sysop" == sysop <vze33mmh@verizon.net> writes:
>>
>> sysop> This script will do what you want.
>>
>> No, this script also follows symlinks erroneously.
>>
>> DO NOT REINVENT DIRECTORY RECURSION (badly).
>>
>> use File::Find
>>
>> use File::Find
>>
>> Please.
>>
>Hmmm, me thinks you've had too much caffine recently...
Methinks you're applying for a negative scorefile entry.
Perhaps Randal has a reason that you just do not know of. Do
you know who Randal is? If you think he said something wrong,
it is best to reconsider five to ten times before you call
him on it, else you could end up embarrassing yourself.
>Perhaps I
>should start any replies I post to this newsgroup with:
Perhaps you should lurk in the newsgroup for a while before
you start posting at all. This is normal procedure for
Usenet newsgroups.
How can you know what is socially acceptable if you do not
observe for a while?
>I am not the Oracle, nor should communication with me be held to be as
>undeniably true as communication with god.
You have actually pretty much hit on the exact reason right there.
Without such a disclaimer folks will copy code here and use it.
Then they will be back to deal with the problems in the code.
Time taken helping them fix it is time not spent helping other
Perl programmers. It is stealing time from our peers.
Better to just give them a good answer the first time.
If you are not reasonably certain that it is a good answer,
then don't post it.
>Do you blame me for trying
>to help a fella out?
Showing a 10 line File::Find solution would have helped him
out even more, and be easier to understand as well.
>if ((-d "$parent\\".$children[$index]) && (!(-l
^^
And you can use forward slashes for the directory separator
on Windows just fine, as long as you don't feed it to the
command interpreter.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
Posting Guidelines: http://mail.augustmail.com/~tadmc/clpmisc.shtml
------------------------------
Date: 20 Nov 2001 06:59:13 GMT
From: fxn@retemail.es (F. Xavier Noria)
Subject: Re: Traversing directories
Message-Id: <9tcv01$4eghb5@news1s.iddeo2.es>
On Tue, 20 Nov 2001 00:10:31 GMT, Rafal Konopka <rafalk@home.com> wrote:
: I need a listing of all the *.htm files in an given directory and all
: its subdirectories. I tried using the example in the Camel book on p.
: 56 but it only reports the first two levels and only on the first
: subfolder it encounters.
:
: My OS is WINNT4. Any pointers would be greatly appreciated.
use File::Find;
perldoc -f glob
-- fxn
------------------------------
Date: Tue, 20 Nov 2001 03:05:31 GMT
From: sysop <vze33mmh@verizon.net>
Subject: Re: { in s///; ?
Message-Id: <pan.2001.11.19.22.04.55.811213.2516@verizon.net>
On Mon, 19 Nov 2001 19:23:50 -0500, Tad McClellan wrote:
> It is not the regex that is the problem, it is the replacement string.
It's not the string, in fact it's the @. It tries to expand the name of
the array and fails when there is no closing brace.
Try these:
s/{/{/g; #works like a charm
s/{/}/g; #also works
s/{/@{}/g; # fails with syntax error at <> line <>, near "@{"
s/{/@{TEST}/g; #fails with In string, @TEST now must be written as ...
------------------------------
Date: Tue, 20 Nov 2001 04:05:26 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: { in s///; ?
Message-Id: <x7oflydr25.fsf@home.sysarch.com>
>>>>> "s" == sysop <vze33mmh@verizon.net> writes:
s> On Mon, 19 Nov 2001 19:23:50 -0500, Tad McClellan wrote:
>> It is not the regex that is the problem, it is the replacement string.
s> It's not the string, in fact it's the @. It tries to expand the name of
s> the array and fails when there is no closing brace.
s> Try these:
s> s/{/{/g; #works like a charm
s> s/{/}/g; #also works
s> s/{/@{}/g; # fails with syntax error at <> line <>, near "@{"
s> s/{/@{TEST}/g; #fails with In string, @TEST now must be written as ...
but those @'s are IN the replacement string. i think tad knows about @
in double quotish contexts. please be aware of who you are following up.
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.stemsystems.com
-- Stem is an Open Source Network Development Toolkit and Application Suite -
----- Stem and Perl Development, Systems Architecture, Design and Coding ----
Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
------------------------------
Date: Tue, 20 Nov 2001 05:04:39 GMT
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: { in s///; ?
Message-Id: <slrn9vjl2j.i6r.tadmc@tadmc26.august.net>
sysop <vze33mmh@verizon.net> wrote:
>On Mon, 19 Nov 2001 19:23:50 -0500, Tad McClellan wrote:
>
>> It is not the regex that is the problem, it is the replacement string.
>
>It's not the string,
Yes it is.
>in fact it's the @. It tries to expand the name of
>the array and fails when there is no closing brace.
Q: Why is it trying to expand an array name?
A: Because it is interpolating.
Q: Why is it interpolating?
A: Because it is in a double quotish string.
Q: What "double quotish string"?
A: The one in the replacement string.
Looks like the problem is in the replacement string, just like I said.
>Try these:
Yes, some of them also show that the problem is in the replacement string.
Why did you want me to try them? I already knew that the problem
was in the replacement string.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Tue, 20 Nov 2001 05:06:48 GMT
From: sysop <vze33mmh@verizon.net>
Subject: Re: { in s///; ?
Message-Id: <pan.2001.11.20.00.11.12.508842.3141@verizon.net>
I just wanna say two things: I was wrong, and I have no clue who Tad is.
His comment was intelligent, and it made me reevaluate what I wrote,
but that doesn't mean I should tremble before daring to post a follow
up to him. I'll certainly look to read his responces in general, as
I'm sure he's knowledgable, especially after your post.
But I'll generally defend what I've said until I understand what was
wrong with it. At the time his comments seemed so quippish their
meaning didn't sink in fully until you responded and I relooked the
whole thread (again).
I was wrong, "braces ... have a special meaning in a regular expression",
however that isn't the problem in this case. I guess it just annoyed
me because I was just harrassed via email for forgetting to deal with
symlinks in directory recursion in another thread. I'm sorry.
Please forgive me! ;)
PS> So what did Tad do that's notable?
On Mon, 19 Nov 2001 23:05:26 -0500, Uri Guttman wrote enough to get
through my thick skull.
------------------------------
Date: Tue, 20 Nov 2001 05:42:52 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: { in s///; ?
Message-Id: <x7herqdmjq.fsf@home.sysarch.com>
>>>>> "s" == sysop <vze33mmh@verizon.net> writes:
s> But I'll generally defend what I've said until I understand what
s> was wrong with it. At the time his comments seemed so quippish
s> their meaning didn't sink in fully until you responded and I
s> relooked the whole thread (again).
well, you have posted a few times recently and they were not too
correct. your html file finder didn't even find those files and you
snipped at randal. i suggest what tad said which is to lurk and read
this group for a while and see whose posts are useful and follow their
lead.
PS> So what did Tad do that's notable?
his posts are knowledgeable, clear and useful.
s> On Mon, 19 Nov 2001 23:05:26 -0500, Uri Guttman wrote enough to get
s> through my thick skull.
i hope this one gets through as well. just jumping in with you ideas is
not always good on usenet. or at least couch it in a way that makes it
know that this is one way to solve a problem. and be open to others
commenting on your posts.
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.stemsystems.com
-- Stem is an Open Source Network Development Toolkit and Application Suite -
----- Stem and Perl Development, Systems Architecture, Design and Coding ----
Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
------------------------------
Date: Tue, 20 Nov 2001 06:12:09 GMT
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: { in s///; ?
Message-Id: <slrn9vjqfn.icp.tadmc@tadmc26.august.net>
sysop <vze33mmh@verizon.net> wrote:
>I just wanna say two things: I was wrong, and I have no clue who Tad is.
[ hideously long URL wrapped ]
http://groups.google.com/groups?as_ugroup=comp.lang.perl.misc&as_uauthors=
tadmc%40augustmail.com&hl=en
>I guess it just annoyed
>me because I was just harrassed via email for forgetting to deal with
>symlinks in directory recursion in another thread. I'm sorry.
I think the (percieved) harrasser might have been one of the
most famous of all "Perl people"...
>Please forgive me! ;)
OK.
>PS> So what did Tad do that's notable?
Uri is probably just referring to me posting here pretty much
daily since before here was here. [1]
It's not notable at all, but you can fast-track yourself into
the clp.misc culture by having a look at the Posting Guidelines
that I put together:
http://mail.augustmail.com/~tadmc/clpmisc.shtml
[1] That is, I've been posting since before comp.lang.perl.misc
was created in 1995. Before that we used the long-defunct
comp.lang.perl newsgroup.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
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 2161
***************************************