I am currently trying to write a perl script to do the following-70.6 -27.5 -60.8 52.9 -123.0 -132.9 110.1 119.9 -62.4 -45.6
Convert the numbers so instead of being between -180 and 180 they are between 0 and 360.
Place the resulting x, y values into blocks of 5. So, now if we have a value of 12.3 it's now placed in the '10-15' block (I hope that makes sense).
Create a two dimensional array, and using the blocked x y values, increment the corresponding element of the array by one
This is what I have managed so far.
I get the following error which I don't understand (google doesn't help)#!/usr/bin/perl use strict; use warnings; my $input = $ARGV[0]; my $x = 0; my $y = 0; my $zeroed_x = 0; my $zeroed_y = 0; my $binned_x = 0; my $binned_y = 0; my @binarray = (); open(INPUT, "$input") || die "Oops! Can't open INPUT file: $!\n"; while(<INPUT>) { $x = substr($_, 0, 6); $y = substr($_, 7, 6); $zeroed_x = ConvertToFromZero($x); $zeroed_y = ConvertToFromZero($y); $binned_x = BinAngles($zeroed_x); $binned_y = BinAngles($zeroed_y); $binarray[$binned_x][$binned_y]++; } for(my $i = 0; $i < @binarray; $i++) { for(my $j = 0; $j < @binarray; $j++) { print "$binarray[$i][$j]\n"; } } ###################################################### sub ConvertToFromZero { my ($axis) = @_; my $zeroed_axis = 0; $zeroed_axis = 180 + $axis; return($zeroed_axis); } ####################################################### sub BinAngles { my ($axisforbin) = @_; my $binnedaxis = 0; $binnedaxis = int($axisforbin/5); return($binnedaxis); }
Any suggestions much appreciated.Use of uninitialized value in concatenation (.) or string at ./script. +pl line 34, <INPUT> line 22.
In reply to Problems processing data for graph by Angharad
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |