in reply to Can't figure out how to include LAST member of the array

How about print "M$End\n"; after the for loop? And note you talk about an array but your code doesn't include one (for output, that is), but I assume you'd probably want to push elements onto a new array instead of printing them.

BTW, your regexes for getting the numbers from the input aren't quite right, the + quantifier needs to be inside the capture group, and since you're already using regexes, you can use them for validation too. For example, my ($num_1) = $input1 =~ m/^m(\d+)$/i or die "bad input: $input1";

A few edits shortly after posting.

Replies are listed 'Best First'.
Re^2: Can't figure out how to include LAST member of the array
by perlynewby (Scribe) on Feb 09, 2021 at 20:52 UTC

    You're right, I want to push it into some hash once I knew how to tackle the last element. I will make that change and for my regex as well. Update: I think I am going to create a table for the values of each metal and via then reference those from a table. Not sure how I will do that yet. I will try. thanks!