I just started learning perl. I attempted to make a simple calculator that takes input from the command line. Input: 5 * 10. Output 50. But instead, it just prints 5. Here’s the code.
#!usr/bin/perl
use strict;
use warnings;
my $op = $ARGV[1];
my $outpt = eval("return $ARGV[0]"."$op"."$ARGV[2]");
print "$outpt"."n";
I’m sure that I’m making some obvious mistake but I have no clue what it is. Any advice would be appreciated.
I tried to input all as one string instead, but that resulted in terminal output no matches found. How should I fix the error.
Anonymous is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.