Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ##Author:Nikos Vaggalis
- ##Licensed under Artistic License 1.0
- ##Accompanying code of the "Advanced Perl regular expressions - the pattern code express"
- ##article on i-programmer.info
- ##URL to full article: http://bit.ly/1QnpfmX
- use Win32;
- use Win32::API;
- use Cwd;
- use File::Spec::Functions;
- use File::Find;
- use File::Basename;
- use File::Copy qw(move);
- use feature 'state';
- use HTML::Entities qw(decode_entities);
- my $dir;
- choose_dir();
- print ("Enter a string to search: ") && (my $search=<STDIN>);
- chomp $search;
- find(\&wanted,($dir));
- sub wanted {
- state $count=1;
- print "\n file current: ",$File::Find::name,"\n";
- if (!-d $File::Find::name and
- $File::Find::name=~
- /(??{ $search=~s@(&\#x....;)(?{ if (defined($1))
- {decode_entities($1)}})@$^R@xg; quotemeta $search})/xi
- )
- {
- print "found file $count : ",$File::Find::name,"\n";
- $count++;
- }
- }
- sub choose_dir {
- my $SHBrowseForFolder=new Win32::API('shell32.dll','SHBrowseForFolder','P','N');
- my $SHGetPathFromIDList=new Win32::API('shell32.dll','SHGetPathFromIDList','NP','N');
- my $display="CHOOSE starting directory...";
- my $BrowseInfo=pack('LLLpLLLL',0,0,0,$display,0,0,0,0,0);
- my $pidl=$SHBrowseForFolder->Call($BrowseInfo);
- $dir=pack('x100');
- $SHGetPathFromIDList->Call($pidl,$dir);
- $dir =~ s/\0//g;
- chdir $dir;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement