#!/usr/bin/perl -n use strict; use warnings; our $total; BEGIN { $total = 0; } $total += $_; END { print $total, "\n"; }