Re: File::Find
From: Gunnar Hjalmarsson (noreply_at_gunnar.cc)
Date: 07/06/04
- Next message: Randal L. Schwartz: "Re: SV: File::Find"
- Previous message: Rod Za: "Help with array reference that has a HASH reference."
- In reply to: Jakob Kofoed: "SV: File::Find"
- Next in thread: Randal L. Schwartz: "Re: SV: File::Find"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
To: beginners@perl.org Date: Tue, 06 Jul 2004 00:38:52 +0200
Jakob Kofoed wrote:
> I used find2perl to get the syntax of File::Find:
<snip>
> sub wanted {
> print("$name\n");
> }
>
> Which gives me the result I want - printed to STDOUT - but to
> change this to handle every file/folder (and get the top folder
> name for renaming) is what I hoped some of you could "hint" me
> with.
Okay. So, obviously you'd better change the wanted() function, right?
I think I would have wanted() store the paths in an array instead of
printing them.
perldoc -f unshift
To exclude those paths you don't want to change, you can do for instance:
unless ($name =~ /\.dat$/ or $name eq $ARGV[0]) {
unshift @paths, $name;
}
Then I would loop through @paths and rename the paths.
perldoc -f rename
You may find the File::Basename and File::Spec modules useful.
Time for you to give it a serious try? I think so. Please feel free to
ask for help if you encounter any specific difficulties.
-- Gunnar Hjalmarsson Email: http://www.gunnar.cc/cgi-bin/contact.pl
- Next message: Randal L. Schwartz: "Re: SV: File::Find"
- Previous message: Rod Za: "Help with array reference that has a HASH reference."
- In reply to: Jakob Kofoed: "SV: File::Find"
- Next in thread: Randal L. Schwartz: "Re: SV: File::Find"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|