perlynewby has asked for the wisdom of the Perl Monks concerning the following question:
This code pretends to build a layer progression as per user input but I cannot think of a way to get the last layer into the print out
Simple task (so I thought!)- building a hierarchical progression of layers. Say the user wants to build a metal stack from M1 to M5, ie: M1->v1->M2->v2->M3->v3->M4->v4->M5.
I cannot figure out how to add the last metal (M5) into my logic, any ideas on this?
In fact, I want to add some dimensions to these metals and make sure the via is laid out within those dimensions. IS there a Perl library that I can use for that?? but that's for a later day after I complete the last array member
Anyways, this is what I have so far.
#!/usr/bin/perl use 5.14.2; use strict; use warnings; use Data::Dumper; use diagnostics; sub metal_stack_order { my @unsorted =@_ ; #make sure to arrange to ascending order my @sorted = sort { $a <=>$b} @unsorted; my ($Start,$End)=($sorted[0],$sorted[1]); for (my $i=$Start; $i <= ($End-1) ; $i++){ print "M$i --> V$i-->"; } } say "Enter Lowest metal layer like => \"m1\"\n"; my $input1=<>; say " Enter Highest metal like => \"m5 \"\n"; my $input2=<>; #parsing the metal layer (digits) my ($num_1)=$input1=~ m/(\d)+/; my ($num_2)=$input2=~ m/(\d)+/; #Ony exception, no equal metal layers if ($num_1 == $num_2){ say "You cannot do a layout the same layer\n"; exit; } metal_stack_order($num_1,$num_2);
Thanks for the help!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Can't figure out how to include LAST member of the array
by haukex (Archbishop) on Feb 09, 2021 at 19:41 UTC | |
by perlynewby (Scribe) on Feb 09, 2021 at 20:52 UTC | |
|
Re: Can't figure out how to include LAST member of the array
by jdporter (Paladin) on Feb 09, 2021 at 20:27 UTC | |
by perlynewby (Scribe) on Feb 09, 2021 at 20:59 UTC | |
|
Re: Can't figure out how to include LAST member of the array
by kcott (Archbishop) on Feb 10, 2021 at 05:10 UTC |