Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re^3: Open a folder

by clueless newbie (Chaplain)
on Jan 08, 2013 at 16:49 UTC ( #1012279=note: print w/replies, xml ) Need Help??


in reply to Re^2: Open a folder
in thread Open a folder

Since you mentioned File::Find ... Change the sub _SizeAndMD5 to suit your problem.

#! use strict; use warnings; use File::Find; use Digest::MD5::File; no warnings "File::Find"; use Smart::Comments; local *wanted=sub { if (-d $File::Find::name) { # directory } elsif ($File::Find::name =~ m{\.txt$}i) { # a file of interest print "for $File::Find::name - @{[_SizeAndMD5($File::Find::nam +e)]}\n"; } }; # wanted # Do something based on the file's content local *_SizeAndMD5=sub { my ($filename_S)=@_; return (-e $filename_S ? sprintf("%8.8lx-%32.32s",-s $filename_S,D +igest::MD5::File::file_md5_hex($filename_S)) : undef); }; # _SizeAndMD5: File::Find::find({ no_chdir=>1,wanted=>\&wanted },@ARGV); exit;

This will process all of the files with a ".txt" extension below the directories specified by @ARGV.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1012279]
help
Chatterbox?
[chacham]: android studio is such a pain
[Corion]: I found Android Studio quite nice as a Java IDE, but then, I didn't try anything serious with it
[chacham]: it is a nice ide. its just that upgrading it always causes issues with mismatched versions of whatever
[Corion]: chacham: Oh, yes, reinstalling all the SDK versions and Gradle and whatnot, yes, even in the short time I used it (2 weeks?) I felt that pain

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (5)
As of 2017-03-29 07:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Should Pluto Get Its Planethood Back?



    Results (344 votes). Check out past polls.