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)"; }} } } }

In reply to Re: Extraction of List of Coordinates by ikegami
in thread Extraction of List of Coordinates by EchoAngel

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.