Skip to content

Instantly share code, notes, and snippets.

@MattOates
Created February 14, 2014 18:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MattOates/9006327 to your computer and use it in GitHub Desktop.
Save MattOates/9006327 to your computer and use it in GitHub Desktop.
Quick test of interlaced recursive function and template stuff in Mojolicious
#!/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