Re: File::Find .. still confused slightly

2017-07-05 Thread Harry Putnam
rea...@newsguy.com (Harry Putnam) writes: > What surprised me is the that when I ran them prefaced with the `time' > utility, I see the sloppy mess I wrote is nearly twice as fast. I may have found a reason. in the find sub {} part you did two returns return unless -f; return

Re: File::Find .. still confused slightly

2017-07-05 Thread Harry Putnam
t your logic depends upon detecting when the > directory name changes, and will therefore not work on the last file > encountered. It also depends upon all of the files in a directory > being scanned sequentially. While that seems to work, it is not > guaranteed by File::Find. > > A sim

Re: File::Find .. still confused slightly

2017-07-05 Thread Jim Gibson
, and will therefore not work on the last file encountered. It also depends upon all of the files in a directory being scanned sequentially. While that seems to work, it is not guaranteed by File::Find. A simpler method for counting files in each directory would be to use a hash

File::Find .. still confused slightly

2017-07-05 Thread Harry Putnam
Working on script using File::Find to count the number of news posts in a semi-extensive hierarchy. As some may know, news posts are commonly stored in numeric named files, one file per posting. The following script tries to plow thru a hierarchy returning the directory name and file count

Re: File::Find report file count per directory

2017-06-28 Thread Harry Putnam
urn unless /\A\d+\z/; $oacnt++; if ($data{$File::Find::dir}++ == 0 ) { if ($cnt) { printf "%-17s %d\n",$d, $cnt; } $cnt = 0; } $d = $File::Find::dir; $cnt ++; }, $dir; printf

Re: File::Find report file count per directory

2017-06-28 Thread Harry Putnam
urn unless /\A\d+\z/; $oacnt++; if ($data{$File::Find::dir}++ == 0 ) { if ($cnt) { printf "%-17s %d\n",$d, $cnt; } $cnt = 0; } $d = $File::Find::dir; $cnt ++; }, $dir; printf

Re: File::Find report file count per directory

2017-06-28 Thread Jim Gibson
y) for each > directory. > > I know that all the information I want to extract is available in > File::Find. > > Just having trouble seeing how to get at it when I want it. > > Connecting the directory name with the file count is the rub for me. > > I googled extensively

File::Find report file count per directory

2017-06-28 Thread Harry Putnam
1) I want to count numeric named files in each directory. 2) I want to capture the name of the directory those files are in 3) I want to print the directory name and the count (if any) for each directory. I know that all the information I want to extract is available in File::Find. Just

Re: Confused with File::Find

2017-06-25 Thread Harry Putnam
and...@geekuni.com (Andrew Solomon) writes: [...] > The way it works it that `find` is traversing through the directories and > `$File::Find::dir` is the directory it's *in* when it calls your subroutine > on `$File::Find::name` which is inside that directory. When it was sitting >

Re: Confused with File::Find

2017-06-24 Thread Andrew Solomon
Here's a small tweak to your initial script which goes some way toward shedding light on what was going wrong: #!/usr/bin/env perl use strict; use warnings; use File::Find; use feature 'say'; my $d = './one'; find sub { return if -f; say $File::Find::name; say "\$File::Find

Re: Confused with File::Find

2017-06-24 Thread Harry Putnam
shlo...@shlomifish.org (Shlomi Fish) writes: > $File::Find::dir is the containing directory of the path item (= the > dirname in http://perldoc.perl.org/File/Basename.html ). Finally, > note that File::Find has OK, I guess I follow that. As you see in my reply to Andrew S, I kind of f

Re: Confused with File::Find

2017-06-24 Thread Harry Putnam
erstand what is happening. >> find sub { >> return if -f; >> print "\$File::Find::dir<$File::Find::dir>\n"; >> }, $d; Seemed to me, would do that. Skip -f type files and print all directory names. Instead I see: >> Output: >>

Re: Confused with File::Find

2017-06-24 Thread Shlomi Fish
Hi Harry! On Fri, 23 Jun 2017 16:56:13 -0400 Harry Putnam <rea...@newsguy.com> wrote: > Trying for a better understand of using File::Find, butI'm missing > something pretty basic I think > > First: The directory structure in this test: > > ./one/tst.pl > two/

Re: Confused with File::Find

2017-06-24 Thread Andrew Solomon
Hi Harry What do you want your code to do? Andrew On Fri, Jun 23, 2017 at 9:56 PM, Harry Putnam <rea...@newsguy.com> wrote: > Trying for a better understand of using File::Find, butI'm missing > something pretty basic I think > > First: The directory structure in this test

Confused with File::Find

2017-06-23 Thread Harry Putnam
Trying for a better understand of using File::Find, butI'm missing something pretty basic I think First: The directory structure in this test: ./one/tst.pl two/tst.pl three/tst.pl So each directory in the layering has the same type -f file in it. Or ls -R ./one ./one: tst.pl

File::Find help

2013-01-10 Thread punit jain
Hi, I have a requirement where I have directory structure like : - test -- test/user1/files, test/user2/files, test/user3/files etc. under sub-directories with usernames I have file with name usersettings. So the final structure as : - test / user1 / usersettings user2 / usersettings

File:: Find help

2013-01-10 Thread punit jain
/bin/perl use strict; use warnings; use File::Basename qw(basename dirname); use File::Find qw(find); use File::Find::Rule; my $indir = shift; my $Users = {}; my @userdirs=File::Find::Rule-maxdepth(1)-directory-in($indir); # this will give me user directories which I want only to depth 1

Re: File:: Find help

2013-01-10 Thread David Precious
(basename dirname); use File::Find qw(find); use File::Find::Rule; [...] find( sub { print $File::Find::name; if ($File::Find::name =~ /Contacts/ -s $File::Find::name 0 ) { print $File::Find::name; # do some

Re: File:: Find help

2013-01-10 Thread John W. Krahn
File::Find qw(find); use File::Find::Rule; my $indir = shift; my $Users = {}; Why not just use a hash instead of a reference to a hash? my @userdirs=File::Find::Rule-maxdepth(1)-directory-in($indir); # this will give me user directories which I want only to depth 1. foreach my $dir

Re: File:: Find help

2013-01-10 Thread punit jain
I think the issue is as you mentioned exporting find from File::Find::Rule. However File::Find I am not sure I will get that flexibility to search only 1 level depth. On Thu, Jan 10, 2013 at 6:07 PM, David Precious dav...@preshweb.co.ukwrote: On Thu, 10 Jan 2013 17:56:18 +0530 punit jain

RE: File::Find::Object::Rule problem

2012-04-23 Thread Jack Maney
important, but manipulates things for other methods to use. What you want to do instead is set up the rules for $plf and then call the start method separately: use strict; use warnings; use Data::Dumper; use File::Find::Object::Rule ; my $plf = File::Find::Object::Rule-file-name(*.pl); $plf-start

Re: File::Find::Object::Rule problem

2012-04-23 Thread Shlomi Fish
Data::Dumper; use File::Find::Object::Rule ; my $plf = File::Find::Object::Rule-file-name(*.pl); $plf-start(./); while ( my $perl_file = $plf-match ){ print $perl_file\n; } If you're familiar with DBI, you can think of $plf as a statement handle, setting up the rules ('-file

Re: File::Find::Object::Rule problem

2012-04-23 Thread Shlomi Fish
is set up the rules for $plf and then call the start method separately: use strict; use warnings; use Data::Dumper; use File::Find::Object::Rule ; my $plf = File::Find::Object::Rule-file-name(*.pl); $plf-start(./); while ( my $perl_file = $plf-match ){ print

Re: File::Find::Object::Rule problem

2012-04-23 Thread Manfred Lotz
anything important, but manipulates things for other methods to use. What you want to do instead is set up the rules for $plf and then call the start method separately: use strict; use warnings; use Data::Dumper; use File::Find::Object::Rule ; my $plf = File

Re: File::Find::Object::Rule problem

2012-04-23 Thread Manfred Lotz
to the documetation which makes it very convenient to work with the package. use strict; use warnings; use Data::Dumper; use File::Find::Object::Rule ; my $plf = File::Find::Object::Rule-file-name(*.pl); $plf-start(./); while ( my $perl_file = $plf-match ){ print $perl_file\n

Re: File::Find::Object::Rule problem

2012-04-23 Thread Shlomi Fish
: use strict; use warnings; use Data::Dumper; use File::Find::Object::Rule ; my $plf = File::Find::Object::Rule-file-name(*.pl); $plf-start(./); while ( my $perl_file = $plf-match ){ print $perl_file\n; } If you're

File::Find::Object::Rule problem

2012-04-22 Thread Manfred Lotz
Hi, I'm trying out File::Find::Object::Rule and get a problem. Here a minimal example: #! /usr/bin/perl use strict; use warnings; use Data::Dumper; use File::Find::Object::Rule ; my $plf = File::Find::Object::Rule-file-name(*.pl)-start( ./ ); while ( my $perl_file = $plf-match

Re: File::Find script questions

2011-07-19 Thread Marc
. Could you recommend a couple that you like? Thanks again, Marc -- #!/usr/bin/perl use strict; use warnings; use File::Find; use File::Slurp; my $path_to_search = $ENV{HOME}.'/public_html'; my $file_name = 'error_log'; my $from_address = 'f...@me.com'; my $to_address

Re: File::Find script questions

2011-07-19 Thread Uri Guttman
$foo_text ; $mailer-close() ; M find(\wanted, $path_to_search); M sub wanted { Mreturn if $_ ne $file_name; Mmy $subject = substr $File::Find::name, length($path_to_search); # removes /home/USER/public_html from the subject bah. that is a very silly way to do that. also

File::Find script questions

2011-07-18 Thread Marc
. Also, do I really need the foreach block in there? I couldn't get it to work without it, but it seems like I should be able to. =:\ Thanks, Marc #!/usr/bin/perl use strict; use warnings; use File::Find; use File::HomeDir; my $path_to_search = File

Re: File::Find script questions

2011-07-18 Thread Hal Wigoda
#!/usr/bin/perl use strict; use warnings; use File::Find; use File::HomeDir; my $path_to_search = File::HomeDir-my_home.'/public_html'; my $file_name      = 'error_log'; my $from_address   = 'x...@xxx.com'; my $to_address     = 'x...@xxx.com'; my $mail_app

Re: File::Find script questions

2011-07-18 Thread John W. Krahn
really need the foreach block in there? I couldn't get it to work without it, but it seems like I should be able to. =:\ Thanks, Marc #!/usr/bin/perl use strict; use warnings; use File::Find; use File::HomeDir; my $path_to_search = File::HomeDir-my_home

Re: File::Find script questions

2011-07-18 Thread Uri Guttman
HW == Hal Wigoda hal.wig...@gmail.com writes: HW Why clean it up when it works and is not obfusticating. because he asked for comments and it will be educational to all on the list. uri -- Uri Guttman -- uri AT perlhunter DOT com --- http://www.perlhunter.com -- Perl

Re: File::Find script questions

2011-07-18 Thread Uri Guttman
be able Mto. =:\ M use strict; M use warnings; good. M use File::Find; M use File::HomeDir; M find(\wanted, $path_to_search); M sub wanted { Mif ($File::Find::name =~ /$file_name/) { it would be much cleaner IMO to collect the paths of the files you want

unable to remove the ./ when using File::Find::name

2011-04-20 Thread Agnello George
Hi I have script where i need to go in to a directory and put all files in to a array if ( chdir ($dirtemp) ) { find (sub { push @all , $File::Find::name}, .); my %selectfiles = qw( /classes/mail.class.php classes/dealer.class.php classes/memcache.class.php classes/phpmailer classes

Re: unable to remove the ./ when using File::Find::name

2011-04-20 Thread Shlomi Fish
On Wednesday 20 Apr 2011 12:50:45 Agnello George wrote: Hi I have script where i need to go in to a directory and put all files in to a array if ( chdir ($dirtemp) ) { find (sub { push @all , $File::Find::name}, .); my %selectfiles = qw( /classes/mail.class.php classes

Re: unable to remove the ./ when using File::Find::name

2011-04-20 Thread Agnello George
On Wed, Apr 20, 2011 at 4:14 PM, Shlomi Fish shlo...@iglu.org.il wrote: On Wednesday 20 Apr 2011 12:50:45 Agnello George wrote: Hi I have script where i need to  go in to a directory and put all files in to a array if ( chdir ($dirtemp) ) {  find (sub { push @all , $File::Find::name

Re: unable to remove the ./ when using File::Find::name

2011-04-20 Thread Agnello George
On Wed, Apr 20, 2011 at 4:14 PM, Shlomi Fish shlo...@iglu.org.il wrote: On Wednesday 20 Apr 2011 12:50:45 Agnello George wrote: Hi I have script where i need to  go in to a directory and put all files in to a array if ( chdir ($dirtemp) ) {  find (sub { push @all , $File::Find::name

Re: unable to remove the ./ when using File::Find::name

2011-04-20 Thread Shlomi Fish
Hi Agnello, On Wednesday 20 Apr 2011 13:59:24 Agnello George wrote: On Wed, Apr 20, 2011 at 4:14 PM, Shlomi Fish shlo...@iglu.org.il wrote: On Wednesday 20 Apr 2011 12:50:45 Agnello George wrote: You can remove the ./: [CODE] foreach my $filename (@all) { my

Re: unable to remove the ./ when using File::Find::name

2011-04-20 Thread Agnello George
On Wed, Apr 20, 2011 at 4:34 PM, Shlomi Fish shlo...@iglu.org.il wrote: Hi Agnello, On Wednesday 20 Apr 2011 13:59:24 Agnello George wrote: On Wed, Apr 20, 2011 at 4:14 PM, Shlomi Fish shlo...@iglu.org.il wrote: On Wednesday 20 Apr 2011 12:50:45 Agnello George wrote: You can remove the

Re: unable to remove the ./ when using File::Find::name

2011-04-20 Thread Shawn H Corey
On 11-04-20 06:55 AM, Agnello George wrote: Thanks a lot , but was just wondering if i could ignore it in the File::Find function Yup. my @all = qw( /classes/mail.class.php classes/dealer.class.php classes/memcache.class.php classes/phpmailer classes/phpmailer/.htaccess classes/phpmailer

Re: File::Find usage

2010-07-24 Thread John W. Krahn
Unknown User wrote: I have this script to find out where a perl module is on my machine: [unkn...@knowme:~/bin]$ cat findmodule #!/usr/bin/perl -w use File::Find; use strict; if ($ENV{INC} ) { # INC=PATH1:PATH2 ./getmodule perldoc perlrun [ SNIP ] PERL5LIBA list

File::Find usage

2010-07-23 Thread Unknown User
I have this script to find out where a perl module is on my machine: [unkn...@knowme:~/bin]$ cat findmodule #!/usr/bin/perl -w use File::Find; use strict; if ($ENV{INC} ) { # INC=PATH1:PATH2 ./getmodule module1 module2 module3 ... for my $toadd (split(/:/,$ENV{INC

Re: File::Find and top level directory

2010-04-25 Thread Shlomi Fish
On Saturday 24 Apr 2010 22:00:56 Harry Putnam wrote: When using File::Find; Is there any built in way to know when you are in the top level of one of the directories in @directories? I mean besides grepping $File::Find::dir. I know that give the current directory name and of course

File::Find and top level directory

2010-04-24 Thread Harry Putnam
When using File::Find; Is there any built in way to know when you are in the top level of one of the directories in @directories? I mean besides grepping $File::Find::dir. I know that give the current directory name and of course the top directory could be massages out with something like

Re: good practice in File::Find

2010-03-09 Thread Harry Putnam
Harry Putnam rea...@newsguy.com writes: Or perhaps: return if $File::Find::dir !~ /$dir_rgx/; Thanks. or Like I've done in he code below. Just let the dir_rgx be a selector and not worry about pulling the next line immediately. I've thought about using `stat' to allow only

good practice in File::Find

2010-03-08 Thread Harry Putnam
there. The idea being to allow you to focus a search without having to know the exact name of the newsgroup[s]. You would at least be searching a group with the string `linux.' in it. So what I'm curious about is if it would be good to `next' out if the File::Find::dir does not contain linux\. Like: next

Re: good practice in File::Find

2010-03-08 Thread Harry Putnam
Harry Putnam rea...@newsguy.com writes: [...] find( sub { ## if we have a directory name that matches if($File::Find::dir =~ /$dir_rgx/){ ## if that directory has files with all numeric names if(/^\d+$/){ ## Open the files and search

Re: good practice in File::Find

2010-03-08 Thread Shawn H Corey
Harry Putnam wrote: find( sub { ## if we have a directory name that matches if($File::Find::dir =~ /$dir_rgx/){ ## if that directory has files with all numeric names if(/^\d+$/){ if( ! /\D/ ){ ## Open the files and search for a regex

Re: good practice in File::Find

2010-03-08 Thread John W. Krahn
be in the files there. The idea being to allow you to focus a search without having to know the exact name of the newsgroup[s]. You would at least be searching a group with the string `linux.' in it. So what I'm curious about is if it would be good to `next' out if the File::Find::dir does not contain

Re: good practice in File::Find

2010-03-08 Thread Harry Putnam
John W. Krahn jwkr...@shaw.ca writes: Like: next if(! $File::Find::dir =~ /$dir_rgx/); No. Because you are inside a subroutine you have to use return: return unless $File::Find::dir =~ /$dir_rgx/; Or perhaps: return if $File::Find::dir !~ /$dir_rgx/; Thanks. or Like I've done

Re: File::Find NO RECURSION Howto

2010-03-03 Thread Shlomi Fish
On Monday 01 Mar 2010 19:31:15 Shawn H Corey wrote: Shlomi Fish wrote: Well, Matt S. Trout shared his sentiments about I cannot use CPAN here: http://www.shadowcat.co.uk/blog/matt-s-trout/but-i-cant-use-cpan/ Well, Matt is wrong. You can't always use CPAN. Yes, you can set it up so

File::Find NO RECURSION Howto

2010-03-01 Thread raphael()
Hi, How can I stop File::Find to go below current dir? i.e. no recursion. Although I can use glob or * to get file names in current dir. But I wanted to know if File::Find has a maxdepth limit like linux find. The script I created uses a switch which decides if recursion is allowed

Re: File::Find NO RECURSION Howto

2010-03-01 Thread Shawn H Corey
raphael() wrote: Hi, How can I stop File::Find to go below current dir? i.e. no recursion. Although I can use glob or * to get file names in current dir. But I wanted to know if File::Find has a maxdepth limit like linux find. The script I created uses a switch which decides

Re: File::Find NO RECURSION Howto

2010-03-01 Thread Shlomi Fish
On Monday 01 Mar 2010 13:23:16 raphael() wrote: Hi, How can I stop File::Find to go below current dir? i.e. no recursion. Although I can use glob or * to get file names in current dir. But I wanted to know if File::Find has a maxdepth limit like linux find. Not, by itself

Re: File::Find NO RECURSION Howto

2010-03-01 Thread raphael()
On Mon, Mar 1, 2010 at 6:18 PM, Shawn H Corey shawnhco...@gmail.com wrote: raphael() wrote: Hi, How can I stop File::Find to go below current dir? i.e. no recursion. Although I can use glob or * to get file names in current dir. But I wanted to know if File::Find has a maxdepth limit

Re: File::Find NO RECURSION Howto

2010-03-01 Thread Shlomi Fish
On Monday 01 Mar 2010 15:00:26 raphael() wrote: On Mon, Mar 1, 2010 at 6:18 PM, Shawn H Corey shawnhco...@gmail.com wrote: raphael() wrote: Hi, How can I stop File::Find to go below current dir? i.e. no recursion. Although I can use glob or * to get file names in current dir

Re: File::Find NO RECURSION Howto

2010-03-01 Thread Shawn H Corey
Shlomi Fish wrote: Well, Matt S. Trout shared his sentiments about I cannot use CPAN here: http://www.shadowcat.co.uk/blog/matt-s-trout/but-i-cant-use-cpan/ Well, Matt is wrong. You can't always use CPAN. Yes, you can set it up so you can use it in development, but that doesn't mean you

need some help excluding with file::find::rule

2010-01-22 Thread solaristar
mentioned criteria, any feedback is appreciated #!/usr/bin/perl use strict; use warnings; use File::Find::Rule; use File::Basename qw/basename dirname/; my @data_dir = qw { /data/backups };# list here the data dir if you want to loop on it. foreach my $dir (@data_dir) { print looking

Re: need some help excluding with file::find::rule

2010-01-22 Thread John W. Krahn
solaristar wrote: First please forgive me if this is the wrong way to go about asking this question. I already answered this question on comp.lang.perl.misc. Do you want me to answer it again here? John -- The programmer is fighting against the two most destructive forces in the universe:

About internal working of File::Find

2009-10-28 Thread Harry Putnam
Looking over the perldoc File::Find output (perl 5.8.4) I see at finddepth it says: [...] in part finddepth() works just like find() except that is invokes the wanted function for a directory after invoking it for the direc- tory's contents. It does a postorder traversal

Re: About internal working of File::Find

2009-10-28 Thread Jim Gibson
On 10/28/09 Wed Oct 28, 2009 12:55 PM, Harry Putnam rea...@newsguy.com scribbled: Looking over the perldoc File::Find output (perl 5.8.4) I see at finddepth it says: [...] in part finddepth() works just like find() except that is invokes the wanted function

Re: About internal working of File::Find

2009-10-28 Thread Harry Putnam
the file path and age as an array entry (untested): my @files; my $dir = '/some/directory/path'; find( sub{ my $age = -M $File::Find::name; push( @files, [ $File::Find::name, $age ] ); }, $dir); for my $entry ( sort { $a-[1] = $b[1] } @files

Re: About internal working of File::Find

2009-10-28 Thread Jim Gibson
, if you want to process files in chronological order, in the wanted routine save the file path and age as an array entry (untested): my @files; my $dir = '/some/directory/path'; find( sub{ my $age = -M $File::Find::name; push( @files, [ $File::Find::name, $age

Re: About internal working of File::Find

2009-10-28 Thread Harry Putnam
Jim Gibson jimsgib...@gmail.com writes: [...] See 'perldoc perllol' for more details on constructing and accessing nested data structures in Perl. Will do, and as always you've given a useful and brief run through, thanks. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For

Re: File::Find with chmod trouble debugging

2009-07-08 Thread Harry Putnam
Telemachus telemac...@arpinum.org writes: On Mon Jul 06 2009 @ 3:31, Harry Putnam wrote: Thanks to all ... Now I'm curious about something else: Is the mode in a stat(file) readout something still different than octal or decimal? As John answered, there's more there than just the

File::Find with chmod trouble debugging

2009-07-06 Thread Harry Putnam
anyone tell me how printing of $mode = 0755 turns into 493? #!/usr/local/bin/perl use strict; use warnings; use File::Find; my $myscript; ($myscript = $0) =~ s/^.*\///; ## chmod mode my $mode = 0755; if(!...@argv || $ARGV[0] eq help){ print Usage tripped

AW: File::Find with chmod trouble debugging

2009-07-06 Thread Thomas Bätzler
Harry Putnam asked: The script below is my first usage of perls `chmod', but it appears to be in keeping with the info at perldoc -f chmod. But somehow in the print of $mode it turns into 493... even though it is set to 755. Its just the print though... the actual chmod appears to be

Re: File::Find with chmod trouble debugging

2009-07-06 Thread Chas. Owens
On Mon, Jul 6, 2009 at 08:00, Harry Putnamrea...@newsguy.com wrote: snip Can anyone tell me how printing of $mode = 0755 turns into 493? snip  my $mode = 0755; snip             print hpdb chmod $mode  $fname\n; snip 0755 is 493. More specifically they are two representations of the same

Re: File::Find with chmod trouble debugging

2009-07-06 Thread Telemachus
On Mon Jul 06 2009 @ 7:00, Harry Putnam wrote: Can anyone tell me how printing of $mode = 0755 turns into 493? Yup: what's in $mode is an octal number. Its decimal equivalent is 493. What you really want to print out is the string '0755', but the string and the octal number are not the same

Re: File::Find with chmod trouble debugging

2009-07-06 Thread Harry Putnam
Thanks to all ... Now I'm curious about something else: Is the mode in a stat(file) readout something still different than octal or decimal? I see `33261' show up in the `mode' slot on a file with 755 permissions (from perldoc -f stat: [...]

Re: File::Find with chmod trouble debugging

2009-07-06 Thread John W. Krahn
Harry Putnam wrote: Thanks to all ... Now I'm curious about something else: Is the mode in a stat(file) readout something still different than octal or decimal? I see `33261' show up in the `mode' slot on a file with 755 permissions (from perldoc -f stat: [...]

Re: File::Find with chmod trouble debugging

2009-07-06 Thread Telemachus
On Mon Jul 06 2009 @ 3:31, Harry Putnam wrote: Thanks to all ... Now I'm curious about something else: Is the mode in a stat(file) readout something still different than octal or decimal? As John answered, there's more there than just the permissions. If you check perldoc -f stat, there's

Re: File::Find

2009-05-19 Thread Randal L. Schwartz
Chas == Chas Owens chas.ow...@gmail.com writes: Chas Huh, never looked at File::Finder before, it looks like it would only Chas make sense if you already knew the UNIX find command. I normally see Chas people use File::Find::Rule when they don't want to write their own Chas wanted function

File::Find

2009-05-18 Thread AndrewMcHorney
Hello I looked at the documentation for this function and I find it confusing. What do you pass in to get all the files on drive letter c? Andrew -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/

Re: File::Find

2009-05-18 Thread Chas. Owens
and directory on the c drive. An easy way to create function for find is to use an anonymous subroutine: find sub {}, c:/; If you want to limit the function to files you can check to see if the current item is a file or not with -f: find sub { return unless -f; print $File::Find::name\n }, c

Re: File::Find

2009-05-18 Thread Gunnar Hjalmarsson
AndrewMcHorney wrote: I looked at the documentation for this function and I find it confusing. Try File::Finder for a less confusing interface to *the module* File::Find. -- Gunnar Hjalmarsson Email: http://www.gunnar.cc/cgi-bin/contact.pl -- To unsubscribe, e-mail: beginners-unsubscr

Re: File::Find

2009-05-18 Thread Chas. Owens
On Mon, May 18, 2009 at 19:05, Gunnar Hjalmarsson nore...@gunnar.cc wrote: AndrewMcHorney wrote: I looked at the documentation for this function and I find it confusing. Try File::Finder for a less confusing interface to *the module* File::Find. snip Huh, never looked at File::Finder before

Re: File::Find

2009-05-18 Thread Gunnar Hjalmarsson
Chas. Owens wrote: On Mon, May 18, 2009 at 19:05, Gunnar Hjalmarsson nore...@gunnar.cc wrote: AndrewMcHorney wrote: I looked at the documentation for this function and I find it confusing. Try File::Finder for a less confusing interface to *the module* File::Find. snip Huh, never looked

Re: File::Find

2009-05-18 Thread AndrewMcHorney
to *the module* File::Find. snip Huh, never looked at File::Finder before, it looks like it would only make sense if you already knew the UNIX find command. I normally see people use File::Find::Rule when they don't want to write their own wanted function. 1. http://search.cpan.org/dist/File-Finder/lib/File

Re: File::Find

2009-05-18 Thread Chas. Owens
of the parameters would be a function which would be called once for each file found. snip After these two lines run @files will hold every file on the c drive. my @files; find sub { push @files, $File::Find::name if -f }, c:/; -- Chas. Owens wonkden.net The most important skill a programmer

Re: File::Find

2009-05-18 Thread David Moreno
AndrewMcHorney wrote: Charles I am getting totally confused. All I want is a simple find function call what will return all the files that are in c:\*.*. This is on PC running windows. I thought you mentioned to use file:find() where one of the parameters would be a function which would be

Re: File::Find

2009-05-18 Thread rkb
file:find() where one of the parameters would be a function which would be called once for each file found. snip After these two lines run @files will hold every file on the c drive. my @files; find sub { push @files, $File::Find::name if -f }, c:/; -- I like and often recommend using File

Re: File::Find

2009-05-18 Thread Chas. Owens
:\*.*. This is on PC running windows. I thought you mentioned to use file:find() where one of the parameters would be a function which would be called once for each file found. snip After these two lines run @files will hold every file on the c drive. my @files; find sub { push @files, $File::Find::name

Re: File::Find

2009-05-18 Thread Gunnar Hjalmarsson
AndrewMcHorney wrote: I am getting totally confused. All I want is a simple find function call what will return all the files that are in c:\*.*. File::Find is useful for recursive tasks. If all you want is to list the files in one directory, there are simpler ways. Personally I would use

Re: File::Find

2009-05-18 Thread Greg Eldridge
On Mon, 2009-05-18 at 17:36 -0700, r...@i.frys.com wrote: snip #!/usr/bin/perl use strict; use warnings; use File::Find; use Benchmark qw/cmpthese/; cmpthese( 10, { 'dir' = sub {my @files = `dir /b /a-d /s c:\test` }, 'filefind' = sub {my @files

Re: File::Find

2009-05-18 Thread David Moreno
Greg Eldridge wrote: What Benchmark .pm are you using ? CPAN i/benchmark/ = lists 66 entries, but none of which are simply Benchmark Thanks in advance. http://search.cpan.org/~nwclark/perl-5.8.9/lib/Benchmark.pm -- David Moreno http://twitter.com/damog -- To unsubscribe, e-mail:

Re: File::Find

2009-05-18 Thread rkb
Greg Eldridge wrote: On Mon, 2009-05-18 at 17:36 -0700, r...@i.frys.com wrote: snip What Benchmark .pm are you using ? CPAN i/benchmark/ = lists 66 entries, but none of which are simply Benchmark Thanks in advance. Greg. http://search.cpan.org/~tty/kurila-1.19_0/lib/Benchmark.pm --

Re: File::Find

2009-05-18 Thread Chas. Owens
On Mon, May 18, 2009 at 21:02, Gunnar Hjalmarsson nore...@gunnar.cc wrote: AndrewMcHorney wrote: I am getting totally confused. All I want is a simple find function call what will return all the files that are in c:\*.*. File::Find is useful for recursive tasks. If all you want is to list

Re: File::Find

2009-05-18 Thread Greg Eldridge
http://search.cpan.org/~tty/kurila-1.19_0/lib/Benchmark.pm -- Ron Bergin Thanks to all for replying. Greg. signature.asc Description: This is a digitally signed message part

Re: Help regarding file find

2009-02-23 Thread Dermot
/folder/2.1/2.1.1/cleanup /folder/2.1/2.1.1/2.1.1.1 /folder/2.1/2.1.1/2.1.1.1/test /folder/2.2/2.2.1/2.2.1.2/test Most of the heavy lifting with your requirements can be done with File::Find and File::Path. Good luck, Dp. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional

Help regarding file find

2009-02-22 Thread Rock Lifestyle
--- On Sat, 21/2/09, Rock Lifestyle lifestyle.r...@yahoo.in wrote: From: Rock Lifestyle lifestyle.r...@yahoo.in Subject: Help regarding file find To: beginners@perl.org Date: Saturday, 21 February, 2009, 6:30 PM Hi All,   I am new to any programming language .I am trying to copy one

Re: Help regarding file find

2009-02-22 Thread Gunnar Hjalmarsson
Rock Lifestyle wrote: I am new to any programming language .I am trying to copy one file structure. I have a folder structures which contains setup files, cleanup files and test file snip Now I want to create another file structure where it will copy the directory tree which I have

Help regarding file find

2009-02-21 Thread Rock Lifestyle
Hi All,   I am new to any programming language .I am trying to copy one file structure.    I have a folder structures which contains setup files, cleanup files and test file   like /testplan /testplan/setup /testplan/cleanup /testplan/2.1/setup /testplan/2.1/cleanup

file::find skip subdir

2009-01-12 Thread icarus
I'm trying to all count files in a home dir and all subdirs *except* a subdir called 'backup'. How do I that? thanks in advance. #!/usr/bin/perl use warnings; use strict; use File::Find; my $dir = (/home/foo); my $counter = 0; find( { wanted = \process, no_chdir = 0 }, $dir ); sub process

Re: file::find skip subdir

2009-01-12 Thread Chas. Owens
On Mon, Jan 12, 2009 at 16:05, icarus rsa...@gmail.com wrote: I'm trying to all count files in a home dir and all subdirs *except* a subdir called 'backup'. When you run into the condition where you don't want to recurse further, set $File::Find::prune to 1 (e.g. $File::Find::prune = 1

Re: ignore directories with File::Find?

2008-10-28 Thread protoplasm
On Oct 24, 12:58 pm, [EMAIL PROTECTED] (John W. Krahn) wrote: I couldn't get $File::Find::prune to work on my system but this may be close to what you require: #!/usr/bin/perl use warnings; use strict; use File::Find; eval use File::HomeDir;; $@ and die qq{[err] File::HomeDir

Re: ignore directories with File::Find?

2008-10-24 Thread protoplasm
simple. Here is the code and the output: #!/usr/bin/env perl use File::Find(); eval(use File::HomeDir;); die [err] File::HomeDir not installed. Use \perl -e \use CPAN; install File::HomeDir;\\ to install \n if $@; use strict; use warnings; no warnings 'File::Find'; use 5.010; my $home_directory

Re: ignore directories with File::Find?

2008-10-24 Thread John W. Krahn
be overlooking something simple. Here is the code and the output: #!/usr/bin/env perl use File::Find(); eval(use File::HomeDir;); die [err] File::HomeDir not installed. Use \perl -e \use CPAN; install File::HomeDir;\\ to install \n if $@; use strict; use warnings; no warnings 'File::Find'; use 5.010

ignore directories with File::Find?

2008-10-23 Thread protoplasm
Nautilus mounts user shares. How can I find a particular directory while ignoring hidden folders like .gvfs? Here is my code. #!/usr/bin/env perl use File::Find; eval(use File::HomeDir;); die [err] File::HomeDir not installed. Use \perl -e \use CPAN; install File::HomeDir;\\ to install \n if $@; use

  1   2   3   4   >