in reply to Extraction of List of Coordinates
You're using a hash, but you're treating it as an array. Here's your code with the fix, and using an array.
foreach $element (@list_of_Num_Extraction) { if ($element =~ m/^([0-9]+),([0-9]+)$/) { my $first_num = $1; my $second_num = $2; my $current_num = ($first_num-1)*$NumOfColumns + $second_num; $Unique_Num_List[$current_num] = "($first_num,$second_num)"; } elsif ($element =~ m/^([0-9]+),([0-9]+):([0-9]+),([0-9]+)$/) { my ($num1x,$num1y,$num2x,$num2y) = ($1,$2,$3,$4); # Swap if ($num1x > $num2x) { $num1x ^= $num2x; $num2x ^= $num1x; $num1x ^= $num2x; } if ($num1y > $num2y) { $num1y ^= $num2y; $num2y ^= $num1y; $num1y ^= $num2y; } my $counter1 = 0; my $counter2 = 0; foreach $counter1 ($num1x .. $num2x) { foreach $counter2 ($num1y .. $num2y) { my $current_num = ($counter1-1)*$NumOfColumns + $counter2; $Unique_Num_List[$current_num] = "($counter1,$counter2)"; }} } } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Extraction of List of Coordinates
by Roy Johnson (Monsignor) on Oct 06, 2004 at 02:39 UTC | |
by sgifford (Prior) on Oct 06, 2004 at 05:28 UTC | |
by Roy Johnson (Monsignor) on Oct 06, 2004 at 15:31 UTC |