Created
August 30, 2010 01:33
-
-
Save mfollett/556901 to your computer and use it in GitHub Desktop.
Functional Programming Blog, week 1 example 7
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
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