Results 11 to 16 of 16
Originally Posted by Cabhan
So my regexp line looks like:
Code:
/([0-9.]+)\s+([0-9.]+)\s+([0-9.]+)\s+([0-9.]+)\s+([0-9.]+)\s+([0-9.]+)\s+([0-9.]+)\s+([0-9.]+)\s+([0-9.]+)/;
And you thought my suggestion was pretty crazy?...
Enjoy an ad free experience by logging in. Not a member yet? Register.
- 05-24-2005 #11Linux Engineer
- Join Date
- Feb 2005
- Posts
- 1,044
And you thought my suggestion was pretty crazy?
Originally Posted by Cabhan
- 05-24-2005 #12
If the file is plain text, it doesn't matter what your keyboard is set to. If you have a . , it will be a . . If you have a , , it will be a , .
And scm, yours is crazy cool. Mine is crazy complicated.
And if you're interested, I think the problem with scm's solution could be fixed by doing:
split without anything else is the same as "split /\s+/, $_". Which we don't need.Code:($v1, $v2, $v3, $v4, $v5, $v6, $v7, $v8, $v9) = split;
- 05-24-2005 #13
Well, I finally did it with PERL, here is the code:
open (INFILE, "XXXX");
open (OUTFILE, "> YYYY");
while (<INFILE>)
{
($v1, $v2, $v3, $v4, $v5, $v6, $v7, $v8, $v9) = split;
$xf = $v1 + $v6;
$yf = $v2 + $v7;
if ( $v5 == 1 ) {
print OUTFILE $v1, "\t", $v2, "\t", $xf, "\t", $yf, "\n";
}
}
close INFILE;
close OUTFILE;
Apart from the "split" function, there is other thing that my poor brain has noticed: the ">" symbol is seems to have more meanings other than to point the direction of the process, or what?
There is no hope with awk in my computer (a P4, 2.4 GHz, 1Gb RAM with SuSE9.1 personal). It can read and print values in decimal form. It can even calculate with decimals in the console, but not through the program. Here is the code:
{
if ($5 == 1)
{ OFS = "\t" ; ORS = "\n" ; print $1, $2, $1 + $6, $2 + $7 ; }
}
It still produces things without decimal values like this:
64 414 100 432
64 439 71 406
64 464 67 465
64 489 66 491
64 539 70 563
64 564 72 595
64 589 30 619
64 639 51 675
So, the question is: does the function "BEGIN" has something to do here? I do not really understand very well its meaning and much less how to use it. Well I think that would be a matter for another topic. I could finally make this PERL code to work and that was thanks to your help guys!!! Thanks to Cabhan, Steve and Santa's little helper!!!
Hernan
- 05-24-2005 #14
When you open a file, you specify one of 3 things:
< - Receive input
> - Overwrite file and direct output
>> - Append to file and direct output
So by running
You are actually wiping all previous data in that file, whereasCode:open OUTFILE, "> yyy"
Would take the file, leave all existing data, and add on the new output to the end.Code:open OUTFILE, ">> yyy"
Does that help?
- 05-24-2005 #15
- 05-25-2005 #16Linux Enthusiast
- Join Date
- Jan 2005
- Posts
- 575
The BEGIN rule gets executed before anything is read from the input
file(s).I don't imagine it has anything to do with the strange results
you're getting.


Reply With Quote
