Advertisement
Guest User

Untitled

a guest
Apr 19th, 2015
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.30 KB | None | 0 0
  1. #!/usr/bin/perl
  2.  
  3. my $code = do {
  4. my $x = 1;
  5. my $y = 0;
  6. my $next;
  7. $next = sub {
  8. ($y, $x) = ($x, $x + $y);
  9. return ($next, $x);
  10. };
  11. };
  12.  
  13. my $value;
  14.  
  15. while($code) {
  16. ($code, $value) = $code->();
  17. print "Next value is: $value \n";
  18. if ($value > 100000000) { last };
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement