Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: Can't figure out how to include LAST member of the array

by haukex (Archbishop)
on Feb 09, 2021 at 19:41 UTC ( [id://11128143]=note: print w/replies, xml ) Need Help??


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!

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11128143]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (7)
As of 2024-04-25 08:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found