I am truly a beginner.  Could someone help me understand this syntax out of
a code example from "Learning Perl"?  On line 5 I'm confused as to why "my
$number" is between "foreach" and the ()?  is "my $number part of the loop?

sub running_sum {
   state $sum = 0;
   state @numbers;

  foreach my $number ( @_ ) {
   push @numbers, $number;
   $sum += $number;
  }

say "The sum of (@numbers) is $sum";
}


Thanks,

jon

Reply via email to