in reply to how to program my program to add random numbers?
It still tries to divide by 0 if given the (un)appropriate input.#!/usr/bin/perl use 5.010; use strict; use warnings; use IO::Prompt; my @operand; foreach my $word (qw[a another]) { push @operand, prompt -p => "Type in $word number: ", '-num'; } prompt -p => "What would you like done?", '-1', -menu => [qw[Add Subtract Multiply Divide]]; my $op = {qw[Add + Subtract - Multiply * Divide /]}->{$_}; say "$operand[0] $op $operand[1] = ", eval "$operand[0] $op $operand[1 +]"; __END__
|
|---|