Hello Monks!
This is my current code. I currently have data saved in this aarray which was originally taken from a 2d array.
Right now, I'm trying to make a general list such that if i put "2,4:3,5" it should try to generate a rectangular coordinate of 2,4 2,5 3,4 3,5. But now i realize this won't work if someone puts "2,4:5,2" or "8,5:3:2".
any ideas
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 = $1;
my $num1y = $2;
my $num2x = $3;
my $num2y = $4;
my $counter1 = 0;
my $counter2 = 0;
foreach $counter1 ($num1x .. $num2x) {
foreach $counter2 ($num1y .. $num2y) {
my $current_num = ($counter1 - 1)*$NumOfColumns + $count
+er2;
$Unique_Num_List{$current_num} = "($counter1,$counter2)";
#print "$counter1 - $counter2 \n";
}}
}
}
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.