Building on everyone else's comments and leveraging Math::Calc::Parser, here is a simple yet reasonably secure solution.
#!/usr/bin/env perl use strict; use warnings; use autodie; use feature 'say'; use Math::Calc::Parser 'calc'; open my $in, '<', 'numbers.txt'; open my $out, '>', 'sum.txt'; while (<$in>) { say $out calc $_; } close $out; close $in;
In reply to Re: Summing numbers in a file
by hippo
in thread Summing numbers in a file
by pvfki
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |