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
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |