Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Traversing folders
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  8 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Dirk  
View profile  
 More options Jul 11 2012, 11:40 am
Newsgroups: comp.lang.perl.misc
From: Dirk <dirk.de...@usa.net>
Date: Wed, 11 Jul 2012 08:40:59 -0700 (PDT)
Local: Wed, Jul 11 2012 11:40 am
Subject: Traversing folders
Hi,

I am new to Perl and I am trying to list all the folders within a given folder and I have the following code. I know it is simple but for some reason the program just stops and I am not seeing any error code being returned.

Does anybody have a good example of File::Find that they are willing to share. Examples are easier for me to follow.

#!/usr/bin/perl
#

use warnings;
use strict;
use File::Find;

my $path_name;
$path_name = '/test';

find sub {
        return unless -d;
        print "$File::Find::name\n";

},$path_name;

exit;

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Rainer Weikusat  
View profile  
 More options Jul 11 2012, 11:56 am
Newsgroups: comp.lang.perl.misc
From: Rainer Weikusat <rweiku...@mssgmbh.com>
Date: Wed, 11 Jul 2012 16:56:11 +0100
Local: Wed, Jul 11 2012 11:56 am
Subject: Re: Traversing folders

Dirk <dirk.de...@usa.net> writes:
> I am new to Perl and I am trying to list all the folders within a
> given folder and I have the following code. I know it is simple but
> for some reason the program just stops and I am not seeing any error
> code being returned.

[...]

Works for me.

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Henry Law  
View profile  
 More options Jul 11 2012, 5:12 pm
Newsgroups: comp.lang.perl.misc
From: Henry Law <n...@lawshouse.org>
Date: Wed, 11 Jul 2012 22:12:01 +0100
Local: Wed, Jul 11 2012 5:12 pm
Subject: Re: Traversing folders
On 11/07/12 16:40, Dirk wrote:

> Hi,

> but for some reason the program just stops and I am not seeing any error code being returned.

Hmm; it works for me.  Are you sure you're not getting anything?  Does
"/test" exist?  (That's the only thing I changed before I ran your code).

Try putting some "print" statements in, to make sure it's running at
all.  Or use perl -d.

--

Henry Law            Manchester, England


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Ben Morrow  
View profile  
 More options Jul 11 2012, 5:49 pm
Newsgroups: comp.lang.perl.misc
From: Ben Morrow <b...@morrow.me.uk>
Date: Wed, 11 Jul 2012 22:49:55 +0100
Local: Wed, Jul 11 2012 5:49 pm
Subject: Re: Traversing folders

Quoth Dirk <dirk.de...@usa.net>:

You don't need to call 'exit' unless you want to exit early, or with an
error code. Falling off the end of a Perl program is the usual way to
exit successfully.

This program works correctly for me, with or without the 'exit'. How
exactly are you invoking it, and what output do you see?

Ben


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Hans Mulder  
View profile  
 More options Jul 11 2012, 7:05 pm
Newsgroups: comp.lang.perl.misc
From: Hans Mulder <han...@xs4all.nl>
Date: Thu, 12 Jul 2012 01:05:20 +0200
Local: Wed, Jul 11 2012 7:05 pm
Subject: Re: Traversing folders
On 11/07/12 17:40:59, Dirk wrote:

Does '/test' exist on your system?

What happens if you try $path_name = '..'; ?

-- HansM


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Rainer Weikusat  
View profile  
 More options Jul 12 2012, 12:01 pm
Newsgroups: comp.lang.perl.misc
From: Rainer Weikusat <rweiku...@mssgmbh.com>
Date: Thu, 12 Jul 2012 17:01:09 +0100
Local: Thurs, Jul 12 2012 12:01 pm
Subject: Re: Traversing folders

Ben Morrow <b...@morrow.me.uk> writes:
> Quoth Dirk <dirk.de...@usa.net>:

[...]

JFTR: This is not necessarily always true. For instance, the embedded
perl interpreter Nagios may use for executing plugins written in Perl
complains about plugins which didn't exit 'properly' if there is no
explicit exit statement at the end of the code.

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Henry Law  
View profile  
 More options Jul 12 2012, 2:24 pm
Newsgroups: comp.lang.perl.misc
From: Henry Law <n...@lawshouse.org>
Date: Thu, 12 Jul 2012 19:24:46 +0100
Local: Thurs, Jul 12 2012 2:24 pm
Subject: Re: Traversing folders
On 11/07/12 16:40, Dirk wrote:

I'm home now and I went as far as making "/test" and a couple of
subdirectories on my personal machine, and ran your code exactly as it
is, superfluous "exit" statement and all.  It runs perfectly.  So you
have another problem; if you'd reply to some of the posts we'll try to
help you with it.

henry@eris:~/Perl/tryout$ sudo mkdir /test
henry@eris:~/Perl/tryout$ sudo chown henry:henry /test
henry@eris:~/Perl/tryout$ mkdir /test/one
henry@eris:~/Perl/tryout$ mkdir /test/two
henry@eris:~/Perl/tryout$ ./clpm
/test
/test/two
/test/one

--

Henry Law            Manchester, England


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Dirk  
View profile  
 More options Jul 13 2012, 1:43 pm
Newsgroups: comp.lang.perl.misc
From: Dirk <dirk.de...@usa.net>
Date: Fri, 13 Jul 2012 10:43:15 -0700 (PDT)
Local: Fri, Jul 13 2012 1:43 pm
Subject: Re: Traversing folders
Thanks to everybody for their input. When I first ran the code I was running it for a folder that did not have a lot of sub-folders. When I ran it agains a very large folder I could not verify all folders and it appeared that I had some missing folders. After being able to verify all the folders and it appears that the code did return all sub-folders.

However, I did notice that I am getting a permission error. Something about not being able to change directory.

Thanks again for all the replies.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »