Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re^5: Use Of Glob On File Extensions (find/rule)

by Anonymous Monk
on Nov 19, 2014 at 02:01 UTC ( [id://1107690]=note: print w/replies, xml ) Need Help??


in reply to Re^4: Use Of Glob On File Extensions (find/rule)
in thread Use Of Glob On File Extensions

I'm not sure why you're so determined to use glob. No, you're not heading in the right direction, File::Find doesn't work like that at all.
  • Comment on Re^5: Use Of Glob On File Extensions (find/rule)

Replies are listed 'Best First'.
Re^6: Use Of Glob On File Extensions (find/rule)
by NewToPerl777 (Novice) on Nov 19, 2014 at 02:49 UTC

    I figured it out! I was just being stubborn with glob. I had to read up on the tutorial involving the File::Find for a while until I understood what was going on. This is what I came up with.

    #!/usr/local/bin/perl use strict; use warnings; use File::Find; my @argv; my $dir = $ARGV[0]; find(\&dirRecurs, $dir); sub dirRecurs{ if (-f) { (my $txt = $_) =~ s/pl$/txt/; rename($_, $txt); } if (-d) { (my $txt = $_) =~ s/pl$/txt/; rename($_, $txt); } }

    Thank you for helping me out Anonymous Monk, it is greatly appreciated!

      I copied the wrong thing. This is what I came up with..

      #!/usr/local/bin/perl use strict; use warnings; use File::Find; my @argv; my $dir = $ARGV[0]; find(\&dirRecurs, $dir); sub dirRecurs{ if (-f) { (my $txt = $_) =~ s/pl$/txt/; rename($_, $txt); } }

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1107690]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (5)
As of 2024-04-19 12:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found