I tried to guess what you really wanted ;-)
#!/usr/bin/env perl use strict; use warnings; use Data::Dump; my $sum = 0; SUM: while (<STDIN>) { chomp; last SUM if /q/i; if ( !/[\d\s]+/ ) { print qq(Enter only numbers!\n); # $sum = 0; last SUM; } my @array = split; dd \@array; for (@array) { if ( ( $_ > 0 ) && ( $_ < 21 ) ) { $sum += $_; } else { print qq(Too much!\n); last SUM; } } print qq(\$sum = $sum\n); undef @array; } print qq(This is the end!\n); __END__
Please see also perlsyn.
Regards, Karl
«The Crux of the Biscuit is the Apostrophe»
In reply to Re: simple perl program not working
by karlgoethebier
in thread simple perl program not working
by heman
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |