reciter has asked for the wisdom of the Perl Monks concerning the following question:
Dear monks
I have lakhs of files in a folder, which I have to input in perl and then locate variables(x2, z2 and some_t2). then compare their values (whether x2 >= 0.6, z2>=0.5 and some_t2>=0.4 is true or not) If a files is true for all x2,z2 and some_t2 then either write the filename as output or write that file(whole content) into new file. (my input files has other variable as well, which we don't want to consider for filtration purpose)
example of file$somecontent 1somecontent somecontent $ 0 1 1 1 0 00 somecontent somecontent x2 = 3.6235 z2 = 0.1036 F_eroie = 0.6156 someothervali = 0.9976 somecontent Some_t2 = 0.8456 se_x2 = -0.6545 x2_se = 0.9647 z2_se = 0.6954 --------------------------------- somecontent somecontent $ $ $somecontent
this my pathetic attempt of code. I started with the aim to print filename of single file, on the basis that all condition are true. even then its not working.
#usr/bin/perl use strict; use warnings; for my $i= 6000000 { open (FH, "try_$i.txt") or die"Can't Open file"; my @readline=<FH>; my $filename = <FH>; close(FH); my $pat='/^x2=\s'; my $pat1='/^z2=\s'; my $pat2='/^some_t2=\s'; foreach my $line (@readline) { $pat=~'/^x2=\s'; my $x2=$line; $pat1=~'/^z2=\s'; my $z2=$line; $pat2=~'/^some_t2=\s'; my $some_t2=$line; $x2 >= 0.6 and $z2 >= 0.5 and $some_t2 >= 0.4; } print $filename; close(FH); }
And I got completly puzzled when I tried opening multiple files. All my files are named like out_1, out_2 ,out_3 and so on..so tried using loop opening file as wel.
But it doesn't work as well.
PLease Help (I have textual content as well as numerical values in the file)
|
|---|