Perl scalar variable holds a single string or numeric value. Perl supports many operators on scalars:
- concatenations of string values via the "." (dot) operator
- math functions on numeric values: + - * / % ^^ as well as a rich set of functions
- support operation on own variable: += -= .= ++ -- etc.
# scalar varaible example
$item_name = "Apple";
$item_price = 13.50;
$item_count = 5;
print "The total for $item_count $item_name" . "s" . " will be: " . $item_count * $item_price . " Dollars.\n";
# or alternately
$total = $item_count * $item_price;
$item_name_plural = $item_name . "s";
print "The total for $item_count $item_name_plural will be: $total Dollars.\n";
The Boeing 747-8 is a wide-body jet airliner developed by Boeing Commercial Airplanes. It is 250 feet long, it weighs 987,392 Pounds and costs 357.5 Million US Dollars. A person in Europe asks you to convert the length to meters, the weight to Kilograms and the cost to Euro.
Use the conversion variable values to print 3 lines:
The jet is ___ Meters long.
The jet weighs Kilograms.
The jet costs ___ Million Euro.