Created
February 14, 2014 18:30
-
-
Save MattOates/9006327 to your computer and use it in GitHub Desktop.
Quick test of interlaced recursive function and template stuff in Mojolicious
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
use Mojolicious::Lite; | |
get '/:n' => sub { | |
my $self = shift; | |
$self->render('index'); | |
}; | |
app->start; | |
__DATA__ | |
@@ index.html.ep | |
<!DOCTYPE html> | |
<html> | |
<head><title>Fib <%= $n %></title></head> | |
<body> | |
<ol> | |
<% | |
sub fib { | |
my ($n) = @_; | |
return 1 if $n == 1; | |
$n += fib($n-1); | |
%> | |
<li> | |
<%= $n %> | |
</li> | |
<% | |
return $n; | |
} | |
fib($n); | |
%> | |
</ol> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment