in reply to Rate my fizzbuzz

First of all, here the context for the unaware Fizz_buzz

> If I did this in an interview, would you hire me?

no yet, because it's only an entry filter

Fizz buzz (often spelled FizzBuzz in this context) has been used as an interview screening device for computer programmers. Writing a program to output the first 100 FizzBuzz numbers is a relatively trivial problem requiring little more than a loop and conditional statements in any popular language, and is thus a quick way to weed out applicants with absolutely no programming experience.

(from the WP article, emphasize added)

> What techniques for making my code more compact and less maintainable have I overlooked?

TIMTOWTDI

for short idomatic Perl you could just stack the "Fuzz" behind the "Bizz" for the "double case"

for my $i (1..100) { my $result; $result .= "Fizz" unless $i % 3; $result .= "Buzz" unless $i % 5; $result //= $i; # "unless defined $result;" print "$result\t\t"; print "\n" unless $i % 5; # that's just sugar for nicer tabul +ar view }

the vanilla approach is to use if-elsif-else-chains

for my $i (1..100) { if ( not $i % 15 ) { print "FizzBuzz"; } elsif ( not $i % 3 ) { print "Fizz"; } elsif ( not $i % 5 ) { print "Buzz"; } else { print $i; } print "\t\t"; print "\n" unless $i % 5; # that's just sugar for nicer tabular v +iew }

Cheers Rolf
(addicted to the Perl Programming Language :)
see Wikisyntax for the Monastery