perl -ne "if (/Variable3 (.*)/ > 0.900) { print 1 }" ...

This puts the regular expression into scalar context, which means it will only return a true value on a match or a false value when not matched. $1 is populated with the contents of the first capture group, so you could write something like if (/Variable3 (.*)/ && $1 > 0.900) .... Alternatively, you can put the regular expression into list context, and since it contains capture groups and doesn't use the /g modifier it will return the contents of the capture groups as a list (details in perlop). The following puts the regex into list context and immediately fetches the first item of that list:

perl -ne "if ( (/Variable3 (.*)/)[0] > 0.900 ) { print 1 }" ...

Note that one debugging technique for troubles with one-liners is to put the code in a normal script file first, spell it out a little more verbosely, Use strict and warnings, find the problem (Basic debugging checklist), and then, if you still want to, reduce it back to a one-liner.


In reply to Re: Simple Perl one-liner in command line by Anonymous Monk
in thread 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.