Guest User

Untitled

a guest
May 24th, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. #!/usr/bin/env perl
  2. use strict;
  3. use warnings;
  4. use utf8;
  5.  
  6. use v5.10;
  7. use Readonly;
  8.  
  9. sub numify { $_[0] ? "1" : "0" }
  10.  
  11.  
  12. my $i = 1;
  13. my $result = "";
  14. Readonly my %table => (
  15. "00" => "other",
  16. "10" => "fizz",
  17. "01" => "buzz",
  18. "11" => "fizzbuzz",
  19. );
  20.  
  21.  
  22. loop:
  23. goto end if $i > 100;
  24. my $key = numify($i % 3 == 0) . numify($i % 5 == 0);
  25. goto $table{$key};
  26. fizz:
  27. $result = "Fizz";
  28. goto finally;
  29. buzz:
  30. $result = "Buzz";
  31. goto finally;
  32. fizzbuzz:
  33. $result = "FizzBuzz";
  34. goto finally;
  35. other:
  36. $result = $i;
  37. goto finally;
  38. finally:
  39. say $result;
  40. $i++;
  41. goto loop;
  42.  
  43.  
  44. end:
Add Comment
Please, Sign In to add comment