Skip to content

Instantly share code, notes, and snippets.

@mfollett
Created August 30, 2010 01:33
Show Gist options
  • Save mfollett/556901 to your computer and use it in GitHub Desktop.
Save mfollett/556901 to your computer and use it in GitHub Desktop.
Functional Programming Blog, week 1 example 7
my $get_input = sub { my $ret = <>; chomp $ret; return $ret;};
my $request = sub { print "Please provide your age: "; $get_input->()};
my @prompts = (
$request,
$request,
sub { print "PLEASE PROVIDE YOUR AGE: "; $get_input->() },
sub { say "Fine, whatever, forget it."; return; }
);
my $age;
for my $req (@prompts) { last if $age = $req->() }
say "Your age is $age" if $age;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment