Re: File::Find

From: Gunnar Hjalmarsson (noreply_at_gunnar.cc)
Date: 07/06/04


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


Relevant Pages

  • Re: Aero and Aqua
    ... on Windows you do get a consistent UI for this: ... uninstaller or do *anything* else. ... Application folder so it is not available to other users. ...
    (comp.sys.mac.advocacy)
  • Re: XP footprint on the new class of ultra low cost PCs
    ... I am Technology Director of a public charter school in Massachusetts, ... I configured Office to install on the D: ... The folder is currently ...
    (microsoft.public.windowsupdate)
  • Re: HKEY_CURRENT_USER
    ... Okay thanks the both of you for the replies, ... I did make a backup using the Backup utility before ... After I renamed the folder the entries under Accessories ... The registry editor can't rename "@Accessbility". ...
    (microsoft.public.windowsxp.general)
  • Re: [kde] KDE 3.5.1 Befuddlement
    ... Felinae Silvestrus Catus Domesticus) made me wonder if I had a "KDE" folder ... you used Konstruct to compile the sources. ...
    (KDE)
  • Re: Desktop Problem
    ... > should do is download hijackthis and have someone to view your log, ... > Okay now perform this operation from this website below ... > Folder Options. ...
    (microsoft.public.windowsxp.general)