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)

In reply to filter the files in a folder on the basis of some variable present in them by reciter

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.