Niro* by cho45

#9 Line numbers programming in Perl (FizzBuzz)

Using Filter::Simple with one line and write line numbers program like BASIC. It is very good that perl feels history of programming.

#/usr/bin/perl
BEGIN { use Filter::Simple sub { s{^(\d+)}{";L$1:";}gme; s{goto (\d+)}{goto L$1}gm }; __PACKAGE__->import };

100		$i++;
110		sleep 0.5;
120		goto 999 if $i > 30;
130		goto 180 if $i % 15 == 0;
140		goto 200 if $i %  5 == 0;
150		goto 220 if $i %  3 == 0;
160		print $i, "\n";
170		goto 100;
180		print "Fizz Buzz\n";
190		goto 100;
200		print "Buzz\n";
210		goto 100;
220		print "Fizz\n";
230		goto 100;
999
blog comments powered by Disqus
login