in reply to subtracting numbers

Welcome. If this is a homework or exercise question it may help to post the actual challenge. Assuming that you want to prompt the user to enter one number, then subtract from that a number depending on user input value, try something like this.

#!/usr/bin/perl use strict; use warnings; print "Enter a number\n"; my $number = <>; chomp($number); my $sendthis = ''; if ( $number ) { if ( $number >= 50 ) { $sendthis = $number - 4; } elsif ( $number >= 20 ) { $sendthis = $number - 3; } elsif ( $number >= 10 ) { $sendthis = $number - 2; }else{ $sendthis = $number; } } print "You sent: $sendthis\n";

Replies are listed 'Best First'.
Re^2: subtracting numbers
by frank1 (Monk) on Dec 23, 2020 at 11:27 UTC

    i appreciate