#!/usr/bin/perl
use 5.016;
use warnings;
use Scalar
::Util qw(dualvar looks_like_number
);
sub _fizz_buzz {
dualvar($_[0],
($_[0] % $_[1] ?
"$_[0]" :
(looks_like_number("$_[0]") ? $_[2] : $_[0] . $_[2])
)
)
}
sub fizz { _fizz_buzz($_[0], 3, 'Fizz') }
sub buzz { _fizz_buzz($_[0], 5, 'Buzz') }
sub gizz { _fizz_buzz($_[0], 7, 'Gizz') }
say buzz fizz 1;
say buzz fizz 3;
say buzz fizz 5;
say buzz fizz 15;
say buzz fizz 998;
say gizz buzz fizz 7;
say gizz buzz fizz 21;
say gizz buzz fizz 35;
say gizz buzz fizz 105;
say buzz gizz fizz 105;
say buzz(fizz(1)) + 2;
say fizz(buzz(fizz(1)) + buzz(2));
say gizz(buzz(fizz(15))) . "XXX";
IyEvdXNyL2Jpbi9wZXJsCnVzZSA1LjAxNjsKdXNlIHdhcm5pbmdzOwp1c2UgU2NhbGFyOjpVdGlsIHF3KGR1YWx2YXIgbG9va3NfbGlrZV9udW1iZXIpOwoKc3ViIF9maXp6X2J1enogewoJZHVhbHZhcigkX1swXSwKCQkoJF9bMF0gJSAkX1sxXSA/CgkJCSIkX1swXSIgOgoJCQkobG9va3NfbGlrZV9udW1iZXIoIiRfWzBdIikgPyAkX1syXSA6ICRfWzBdIC4gJF9bMl0pCgkJKQoJKQp9CgpzdWIgZml6eiB7IF9maXp6X2J1enooJF9bMF0sIDMsICdGaXp6JykgfQpzdWIgYnV6eiB7IF9maXp6X2J1enooJF9bMF0sIDUsICdCdXp6JykgfQpzdWIgZ2l6eiB7IF9maXp6X2J1enooJF9bMF0sIDcsICdHaXp6JykgfQoKc2F5IGJ1enogZml6eiAxOwpzYXkgYnV6eiBmaXp6IDM7CnNheSBidXp6IGZpenogNTsKc2F5IGJ1enogZml6eiAxNTsKc2F5IGJ1enogZml6eiA5OTg7CgpzYXkgZ2l6eiBidXp6IGZpenogNzsKc2F5IGdpenogYnV6eiBmaXp6IDIxOwpzYXkgZ2l6eiBidXp6IGZpenogMzU7CnNheSBnaXp6IGJ1enogZml6eiAxMDU7CnNheSBidXp6IGdpenogZml6eiAxMDU7CgpzYXkgYnV6eihmaXp6KDEpKSArIDI7CnNheSBmaXp6KGJ1enooZml6eigxKSkgKyBidXp6KDIpKTsKc2F5IGdpenooYnV6eihmaXp6KDE1KSkpIC4gIlhYWCI7Cg==