I would declare it only once, like this:
#!/usr/bin/env -S perl -n use strict; use warnings; # USAGE: perl np.pl <np.dat our $total; BEGIN{ $total = 0; } $total += $_; END{ print $total }
This seems less verbose while retaining the clarity but it is all subjective, of course.
🦛
In reply to Re: Initialize variable in BEGIN
by hippo
in thread Initialize variable in BEGIN
by BillKSmith
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |