Dear Perl users,

I am very new to Perl, and am only using it in a script together with windows command line code in order to search, compare and print from and to a file.

What I am trying to do is search for a string in an output file, compare the value behind the string to a given value, and depending on the comparison, to print a 1, or not, in another file.

The one-liner(s) I am using now are as follows:

perl -ne "if (/Variable (.*)/ > 0.900) { print 1 }" "C:\Users\Desktop\ +...\output_files\output.txt" > discard\variable.txt perl -ne "if (/Variable2 (.*)/ > 0.900) { print 1 }" "C:\Users\Desktop +\...\output_files\output.txt" > discard\variable2.txt perl -ne "if (/Variable3 (.*)/ > 0.900) { print 1 }" "C:\Users\Desktop +\...\output_files\output.txt" > discard\variable3.txt

For some reason it just doesn't work. The script will print a 1, or not, but the comparison is not correct. It also seems as if after the script is run once, the script will always print the same after that.

I'm sure (and hoping) that there is a very simple solution to my problem. Possibly just the syntax for the comparison?

Thanks in advance, Reuben.

In reply to Simple Perl one-liner in command line by wewantmoore

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.