Hi Ratazong, I am a novice to perl thats why I do so much blunder. I tried another way to filter files. Instead using x2 z2 and all as variable I tried to search them as pattern. but it also having problem can you please check and tell what can I do so it may start working.
#usr/bin/perl use strict; use warnings; use File::Find; use File::stat; my $path='e:\testfolder'; find(\&checkFile, $path); # loop through all files in my directory #--------------------------------- check to be applied on each file -- +----------- sub checkFile { my $fullfilename = $File::Find::name; my $filesize = stat($File::Find::name)->size; my $filename = $_; # --- check for relevance based on expected filenames if ((! ($filename =~ /_obj_pp_comp.txt/ )) && (! ($filename =~ /ob +j.doc/ ))) { return; } if ($filesize == 0) { print ("<!-- \t\tERROR: file $fullfilename is empty. -->\n"); + return; } if (! -f $filename) { print ("<!-- \t\tERROR: file $fullfilename is a directory. -->\ +n"); return; } analyze($fullfilename); } #--------------------------------- work to be done on each relevant fi +le ------------- sub analyze { my @files = $fullfilename; my $pat='/^x2=0.[6-9][0-9][0-9][0-9][0-9]\n'; my $pat1='/^z2=0.[6-9][0-9][0-9][0-9][0-9]\n'; my $pat3='/^some_t2=0.[6-9][0-9][0-9][0-9][0-9]\n'; foreach my $file (@files) { foreach my $file1(@files) { foreach my $files2(@files) { if (($file=~/^$pat/) && ($file1=~/^$pat1/) && ($file2= +~/^$pat3/)) { print "$file IS VALID\n"; system 'mv $file E:\test\some' } else print "not relevant\n" } } } }
In reply to Re^2: filter the files in a folder on the basis of some variable present in them
by reciter
in thread filter the files in a folder on the basis of some variable present in them
by reciter
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |