Re: Finding directories within a tree

2005-10-07 Thread Dave Gray
On 10/7/05, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> Good Afternoon
>
> I am attempting to develop a script that will parse a directory listing and 
> return only directory names that match a given expression.
>
> It would make sense to me to use File::Find to do this but based on the dir 
> structure I am parsing, the amount of overhead to do this is enourmous !
>
> Basically, I have a file structure similar to:
>
> Dir1\Dir2\Support\119404\dirx\diry
> Dir1\Dir3\Support\119893\dirx
> Dir1\Dir4\Support\14\dirx\diry\dirz
> .
> Dir1\Dir1000\Support\100858
>
> I am simply interested in finding the directories directley under the Support 
> dir (ex.119404 from the 1st example) . There is no consistancy to the naming 
> convention other then Dir1 and Support. Dir2 can be many different values.
>
> I tried functionality similar to the following that did work on a much 
> smaller test bed:
>
> my $dirs="I:\\ID_00_000999";
> find sub { push @dirs, $File::Find::dir if $File::Find::dir =~ 
> m/.+[Ss]upport\/\d+$/;}, $dirs;

This is not only processing directories, but any files present as
well. It will probably be a considerable (although untested) speedup
to do something like:

  my $dir="I:\\ID_00_000999";
  our @dirs;
  sub callback {
push @dirs, $_ if /.+[Ss]upport\/\d+$/;
  }
  sub filter {
# we only care about directories
return grep(-d $_, @_);
  }
  find {
wanted=>\&callback,
preprocess=>\&filter,
no_chdir=>1
  }, $dir;
  print @dirs;

Read up on File::Find, and consider putting some prints in your
callbacks to see what's getting called and exactly what it's doing.

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: RE: Finding directories within a tree

2005-10-07 Thread jason_normandin
That worked perfectley.

> 
> From: "Larsen, Errin M HMMA/IT" <[EMAIL PROTECTED]>
> Date: 2005/10/07 Fri PM 02:03:29 EDT
> To: 
> Subject: RE: Finding directories within a tree
> 
> [EMAIL PROTECTED] wrote:
> > Good Afternoon
> > 
> > I am attempting to develop a script that will parse a directory
> > listing and return only directory names that match a given
> > expression.  
> > 
> > It would make sense to me to use File::Find to do this but based on
> > the dir structure I am parsing, the amount of overhead to do this is
> > enourmous !  
> > 
> > Basically, I have a file structure similar to:
> > 
> > Dir1\Dir2\Support\119404\dirx\diry
> > Dir1\Dir3\Support\119893\dirx
> > Dir1\Dir4\Support\14\dirx\diry\dirz
> > .
> > Dir1\Dir1000\Support\100858
> > 
> > I am simply interested in finding the directories directley under the
> > Support dir (ex.119404 from the 1st example) . There is no
> > consistancy to the naming convention other then Dir1 and Support.
> > Dir2 can be many different values.   
> > 
> > I tried functionality similar to the following that did work on a
> > much smaller test bed: 
> > 
> > my $dirs="I:\\ID_00_000999";
> > find sub { push @dirs, $File::Find::dir if $File::Find::dir =~
> > m/.+[Ss]upport\/\d+$/;}, $dirs; 
> > 
> > But in a larger scale dir structure. The performance of this was
> > horrible !! (Since it is looking through the entire structure
> > including dirs under the directory I am trying to match on).  
> > 
> > As you can see form the I:\\ this is on windows, so ls and similar
> > UNIX commands are not available. 
> > 
> > Any thoughts on how I can accomplish this task with the lowest amount
> > of overhead? 
> > 
> > Thanks!
> > Jason
> 
> Hi Jason,
> 
> Did you look into globs?  You need to make a list of every directory
> you're interested in ONCE, then process that list.
> 
> This worked for me:
> 
> 
> # I don't have access to a windows system with Perl
> # installed, but as this is all native perl, it
> # should be fine
> 
> my $dirs='/ID_00_000999';
> my @dirs_found;
> 
> push @dirs_found, $_ while <$dirs/*/[Ss]upport/*>;
> 
> 
> 
> You can check out these perldocs for further info:
> 
> perldoc -f glob
> perldoc File::Glob
> perldoc perlop (look for I/O Operators)   
> 
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> <http://learn.perl.org/> <http://learn.perl.org/first-response>
> 
> 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




Re: Finding directories within a tree

2005-10-07 Thread Dave Gray
On 10/7/05, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> I am receiving numerous amounts of mail but have not filled out any 
> questionnaires giving away any sort of information. If these letters continue 
> being sent to me I will be forced to report you to AOL as spam and possibly 
> other forms to get me taken off of whatever list that I am on. PLEASE take my 
> off of the lists on which I am to receive these annoying messages. thank you 
> very much and have a nice day.
> >
> -- To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>  

Now /that's/ comedy.

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: Finding directories within a tree

2005-10-07 Thread rangerrickca
I am receiving numerous amounts of mail but have not filled out any 
questionnaires giving away any sort of information. If these letters continue 
being sent to me I will be forced to report you to AOL as spam and possibly 
other forms to get me taken off of whatever list that I am on. PLEASE take my 
off of the lists on which I am to receive these annoying messages. thank you 
very much and have a nice day. 
 
SA*
 
 
-Original Message-
From: Gustav Wiberg <[EMAIL PROTECTED]>
To: [EMAIL PROTECTED]; beginners@perl.org
Sent: Fri, 7 Oct 2005 20:06:42 +0200
Subject: Re: Finding directories within a tree


Hi there! 
 
Isn't it possible to use dir - command? (dos-command) which is similar to ls 
 
/G 
- Original Message - From: <[EMAIL PROTECTED]> 
To:  
Sent: Friday, October 07, 2005 7:17 PM 
Subject: Finding directories within a tree 
 
> Good Afternoon 
> 
> I am attempting to develop a script that will parse a directory listing > and 
> return only directory names that match a given expression. 
> 
> It would make sense to me to use File::Find to do this but based on the > dir 
> structure I am parsing, the amount of overhead to do this is enourmous > ! 
> 
> Basically, I have a file structure similar to: 
> 
> Dir1\Dir2\Support\119404\dirx\diry 
> Dir1\Dir3\Support\119893\dirx 
> Dir1\Dir4\Support\14\dirx\diry\dirz 
> . 
> Dir1\Dir1000\Support\100858 
> 
> I am simply interested in finding the directories directley under the > 
> Support dir (ex.119404 from the 1st example) . There is no consistancy to > 
> the naming convention other then Dir1 and Support. Dir2 can be many > 
> different values. 
> 
> I tried functionality similar to the following that did work on a much > 
> smaller test bed: 
> 
> my $dirs="I:\\ID_00_000999"; 
> find sub { push @dirs, $File::Find::dir if $File::Find::dir =~ > 
> m/.+[Ss]upport\/\d+$/;}, $dirs; 
> 
> But in a larger scale dir structure. The performance of this was horrible > 
> !! (Since it is looking through the entire structure including dirs under > 
> the directory I am trying to match on). 
> 
> As you can see form the I:\\ this is on windows, so ls and similar UNIX > 
> commands are not available. 
> 
> Any thoughts on how I can accomplish this task with the lowest amount of > 
> overhead? 
> 
> Thanks! 
> Jason 
> 
> -- > To unsubscribe, e-mail: [EMAIL PROTECTED] 
> For additional commands, e-mail: [EMAIL PROTECTED] 
> <http://learn.perl.org/> <http://learn.perl.org/first-response> 
> 
> 
> 
> 
> -- > No virus found in this incoming message. 
> Checked by AVG Anti-Virus. 
> Version: 7.0.344 / Virus Database: 267.11.13/123 - Release Date: > 2005-10-06 
> 
>  
-- To unsubscribe, e-mail: [EMAIL PROTECTED] 
For additional commands, e-mail: [EMAIL PROTECTED] 
<http://learn.perl.org/> <http://learn.perl.org/first-response> 
 


Re: Finding directories within a tree

2005-10-07 Thread Gustav Wiberg

Hi there!

Isn't it possible to use dir - command? (dos-command) which is similar to ls

/G
- Original Message - 
From: <[EMAIL PROTECTED]>

To: 
Sent: Friday, October 07, 2005 7:17 PM
Subject: Finding directories within a tree



Good Afternoon

I am attempting to develop a script that will parse a directory listing 
and return only directory names that match a given expression.


It would make sense to me to use File::Find to do this but based on the 
dir structure I am parsing, the amount of overhead to do this is enourmous 
!


Basically, I have a file structure similar to:

Dir1\Dir2\Support\119404\dirx\diry
Dir1\Dir3\Support\119893\dirx
Dir1\Dir4\Support\14\dirx\diry\dirz
.
Dir1\Dir1000\Support\100858

I am simply interested in finding the directories directley under the 
Support dir (ex.119404 from the 1st example) . There is no consistancy to 
the naming convention other then Dir1 and Support. Dir2 can be many 
different values.


I tried functionality similar to the following that did work on a much 
smaller test bed:


my $dirs="I:\\ID_00_000999";
find sub { push @dirs, $File::Find::dir if $File::Find::dir =~ 
m/.+[Ss]upport\/\d+$/;}, $dirs;


But in a larger scale dir structure. The performance of this was horrible 
!! (Since it is looking through the entire structure including dirs under 
the directory I am trying to match on).


As you can see form the I:\\ this is on windows, so ls and similar UNIX 
commands are not available.


Any thoughts on how I can accomplish this task with the lowest amount of 
overhead?


Thanks!
Jason

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




--
No virus found in this incoming message.
Checked by AVG Anti-Virus.
Version: 7.0.344 / Virus Database: 267.11.13/123 - Release Date: 
2005-10-06






--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




Re: Finding directories within a tree

2005-10-07 Thread Adriano Ferreira
On 10/7/05, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> Basically, I have a file structure similar to:
>
> Dir1\Dir2\Support\119404\dirx\diry
> Dir1\Dir3\Support\119893\dirx
> Dir1\Dir4\Support\14\dirx\diry\dirz
> .
> Dir1\Dir1000\Support\100858
>
> I am simply interested in finding the directories directley under the Support 
> dir (ex.119404 from the 1st example) . There is no consistancy to the naming 
> convention other then Dir1 and Support. Dir2 can be many different values.

I think you just need to use glob(). Maybe this

   perl -e 'print glob("Dir1/*/Support/*/")

with some tweaking will give you the directories you want.

Best regards,
Adriano.

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




RE: Finding directories within a tree

2005-10-07 Thread Larsen, Errin M HMMA/IT
[EMAIL PROTECTED] wrote:
> Good Afternoon
> 
> I am attempting to develop a script that will parse a directory
> listing and return only directory names that match a given
> expression.  
> 
> It would make sense to me to use File::Find to do this but based on
> the dir structure I am parsing, the amount of overhead to do this is
> enourmous !  
> 
> Basically, I have a file structure similar to:
> 
> Dir1\Dir2\Support\119404\dirx\diry
> Dir1\Dir3\Support\119893\dirx
> Dir1\Dir4\Support\14\dirx\diry\dirz
> .
> Dir1\Dir1000\Support\100858
> 
> I am simply interested in finding the directories directley under the
> Support dir (ex.119404 from the 1st example) . There is no
> consistancy to the naming convention other then Dir1 and Support.
> Dir2 can be many different values.   
> 
> I tried functionality similar to the following that did work on a
> much smaller test bed: 
> 
> my $dirs="I:\\ID_00_000999";
> find sub { push @dirs, $File::Find::dir if $File::Find::dir =~
> m/.+[Ss]upport\/\d+$/;}, $dirs; 
> 
> But in a larger scale dir structure. The performance of this was
> horrible !! (Since it is looking through the entire structure
> including dirs under the directory I am trying to match on).  
> 
> As you can see form the I:\\ this is on windows, so ls and similar
> UNIX commands are not available. 
> 
> Any thoughts on how I can accomplish this task with the lowest amount
> of overhead? 
> 
> Thanks!
> Jason

Hi Jason,

Did you look into globs?  You need to make a list of every directory
you're interested in ONCE, then process that list.

This worked for me:


# I don't have access to a windows system with Perl
# installed, but as this is all native perl, it
# should be fine

my $dirs='/ID_00_000999';
my @dirs_found;

push @dirs_found, $_ while <$dirs/*/[Ss]upport/*>;



You can check out these perldocs for further info:

perldoc -f glob
perldoc File::Glob
perldoc perlop (look for I/O Operators) 

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Finding directories within a tree

2005-10-07 Thread jason_normandin
Good Afternoon

I am attempting to develop a script that will parse a directory listing and 
return only directory names that match a given expression.

It would make sense to me to use File::Find to do this but based on the dir 
structure I am parsing, the amount of overhead to do this is enourmous !

Basically, I have a file structure similar to:

Dir1\Dir2\Support\119404\dirx\diry
Dir1\Dir3\Support\119893\dirx
Dir1\Dir4\Support\14\dirx\diry\dirz
.
Dir1\Dir1000\Support\100858

I am simply interested in finding the directories directley under the Support 
dir (ex.119404 from the 1st example) . There is no consistancy to the naming 
convention other then Dir1 and Support. Dir2 can be many different values.

I tried functionality similar to the following that did work on a much smaller 
test bed:

my $dirs="I:\\ID_00_000999";
find sub { push @dirs, $File::Find::dir if $File::Find::dir =~ 
m/.+[Ss]upport\/\d+$/;}, $dirs;

But in a larger scale dir structure. The performance of this was horrible !! 
(Since it is looking through the entire structure including dirs under the 
directory I am trying to match on).

As you can see form the I:\\ this is on windows, so ls and similar UNIX 
commands are not available.

Any thoughts on how I can accomplish this task with the lowest amount of 
overhead?

Thanks!
Jason

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]