Skip to content

Instantly share code, notes, and snippets.

@crmpicco
Created November 6, 2025 13:28
Show Gist options
  • Save crmpicco/15902395c6dadd0df27008816971538f to your computer and use it in GitHub Desktop.
Save crmpicco/15902395c6dadd0df27008816971538f to your computer and use it in GitHub Desktop.
Perl vat calc
#! /usr/bin/perl
# works out how much VAT you've paid on a given amount
# Change the amount on the next line for the VAT rate
# Uses a while loop to allow multiple calculations
$vat = 17.5;
print "Please enter an amount paid including the VAT or 0 to quit ........ ";
$amount = <STDIN> ;
while ($amount != 0)
{
$Vat = ( $amount - ($amount * 100 / (100 + $vat)));
printf("You paid %.2f VAT\n", $Vat);
print "Please enter another amount paid including the VAT ";
$amount = <STDIN> ;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment