what module could easiely load all files to a @array from a specified folder(and subfolders)?

A

Alont

just tell me the name of module,
my english too poor to can't understand all module help files, forgive
me....
 
P

Paul Lalli

Alont said:
Subject: what module could easiely load all files to a @array from a
specified folder(and subfolders)?
just tell me the name of module,
my english too poor to can't understand all module help files, forgive
me....

File::Find

Paul Lalli
 
A

A. Sinan Unur

Alont said:
just tell me the name of module,

Don't order people around.
my english too poor to can't understand all module help files, forgive
me....

Oh, you put your entire question in the subject line. Don't do that.
(This has nothing to do with your language abilities, it is just common
sense).

Your question was:
what module could easiely load all files to a @array
from a specified folder(and subfolders)?

Well, there is actually a nontrivial choice between using a hash versus
an array to store the list of files, so think about that. It depends on
what you want to do with those files ones you have the names.

Take a look at File::Find or File::Finder.
 
A

Alont

(e-mail address removed) (Randal L. Schwartz)Wrote at 22 Sep 2004
09:23:55 -0700:
use File::Finder; # in CPAN
my @array = File::Finder->type('f')->in($specified_folder);

So simple! but if I only want *.txt file list, should "type('f')"
change to "type('*.txt')" or "type('txt')"?
 
A

Alont

A. Sinan Unur said:
Don't order people around.

sorry soory, it's not what I want describe, it's my failure in english
language, my original meaning is that I've read a lot of CPAN module,
but can't find what I want, in fact I don't want bother people here, I
know everybody have no time to answer stupid question with me, so I
carefully say "just tell me the name"------however, I know what "just"
mean since you tell me :)
 
P

Paul Lalli

Alont said:
(e-mail address removed) (Randal L. Schwartz)Wrote at 22 Sep 2004
09:23:55 -0700:


So simple! but if I only want *.txt file list, should "type('f')"
change to "type('*.txt')" or "type('txt')"?

type is the type of directory entry - 'f' means file. If you want to
restrict your match to files that match only a certain name, you need
another step:

my @array =
File::Finder->type('f')->name('*.txt')->in($specified_folder);

Paul Lalli
 
A

Alont

Paul Lalli said:
type is the type of directory entry - 'f' means file. If you want to
restrict your match to files that match only a certain name, you need
another step:

my @array =
File::Finder->type('f')->name('*.txt')->in($specified_folder);
are you sure that file::find(there haven't a modle named
"Finder")have a object?:

---------- Perl compiler ----------
Can't locate object method "type" via package "File::Find" at
E:\doc\perl\getIt.pl line 11.
Normal Termination
Output completed (0 sec consumed).
---------- Perl compiler ----------
Can't locate object method "name" via package "File::Find" at
E:\doc\perl\getIt.pl line 11.
Normal Termination
Output completed (2 sec consumed).

use File::Find; # in CPAN
my @files =
File::Find->type('f')->name('*.txt')->in($specified_folder);
foreach (@files) {
print @files;
}
 
G

Gerhard M

Alont said:
just tell me the name of module,
my english too poor to can't understand all module help files, forgive
me....

maybe you mean this:
perl -e '@array=<>; #your code' directory/*

this will load all files (content of files, not filename) in directory to @array

Gerhard
 
P

Peter Scott

are you sure that file::find(there haven't a modle named
"Finder")have a object?:

There is indeed a module called File::Finder, it just doesn't come
with Perl. You have to download it from CPAN. But it is simpler
to use than File::Find and so it is worth downloading.

Read how to use File::Finder at
http://search.cpan.org/~merlyn/File-Finder-0.03/lib/File/Finder.pm

Installing it may be as simple as typing
perl -MCPAN -e 'install File::Finder'
(with privileges to write to perl's installation directories)
depending on your type of machine. If you have not done this
before you will have to answer a lot of questions; the defaults
will usually be fine. But there are many modules on CPAN that
can make programming much easier and so it is worth doing. If
you get stuck, see http://www.cpan.org/modules/INSTALL.html .

By the way, you are expressing yourself more clearly than many
people with a better command of English do here.
Your fault as a Government is My failure as a citizen

Quite.
 
K

krakle

Alont said:
just tell me the name of module,
my english too poor to can't understand all module help files, forgive
me....

Here's a better question... If your english is too poor to understand
a plain english help file how is your english going to be sufficient
enough to understand a plain english reply? :)
 
A

Alont

Here's a better question... If your english is too poor to understand
a plain english help file how is your english going to be sufficient
enough to understand a plain english reply? :)

in the beginning I read the help file of File::find ,but can't find a
way to easiely solve my problem(so I doubt if I really all understand
the help file), after Peter Scott tell me there have a module named
"File::finder" from CPAN and He give me an usage example, then,
question over :)
BTW: My reading speed are very slow, but I always do, maybe this is a
way to improve my english level, I also fear if I ask stupid question
here are unmoral, this group always so busy, but if I did, I hope
people forgive me, sometimes I don't post "thank you" to people who
help me, because I think this kind of post also waste people's time in
this busy group.
 
B

Bart Lateur

Alont said:
in the beginning I read the help file of File::find ,but can't find a
way to easiely solve my problem

use File::Find;
my @ls;
find sub {
push @ls, $File::Find::name if -f;
}, "/dir/to/check", "/another/dir/to/check";

# now, look in @ls...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top