#!/usr/bin/perl -w use strict; use warnings; use feature qw(say); use English qw(-no_match_vars); BEGIN { $^W = 1; } sub BEGIN { if ($^W == 1) {say "Let's get started..."} else {die $@} } local $OUTPUT_AUTOFLUSH = 1; local $OUTPUT_RECORD_SEPARATOR = *\ ; print <; if ($calculation =~ /voltage/) { say $type_current; my $current = ; say $type_resistance; my $resistance = ; if ($current =~ /mA/) { $current =~ s/mA//; $current =~ s/(^\s+| )//; $current /= 1000; } else {()} say $ohmlaw . "the voltage of\nthe circuit is " . $current * $resistance . " volts."; ++$i; } elsif ($calculation =~ /current/) { say $type_resistance; my $resistance = ; say $type_voltage; my $voltage = ; say $ohmlaw . "the current of\nthe circuit is ". $voltage / $resistance . " amps., or " . $voltage /($resistance*1000) . " milliAmps."; ++$i; } elsif ($calculation =~ /resistance/) { say $type_current; my $current = ; say $type_voltage; my $voltage = ; if ($current =~ /mA/) { $current =~ s/mA//; $current =~ s/(^\s+| )//; $current /= 1000; } else {()} say $ohmlaw ."the resistance of\nthe circuit is ". $voltage / $current . "ohms."; ++$i; } else {say "That is not a valid answer.\nRetype your answer."} }