~/www/Lesson5/function_generator.pl.html #! /usr/bin/perl -w
use strict;

sub make_saying  {
    my $bless = shift;

    my $newfunc = sub {
        my $target = shift;
        print "$bless, $target!\n";
    };

    return $newfunc;            # Return a closure
}

my $f = make_saying("Bye bye");      # Create a closure
my $g = make_saying("Hello");  # Create another closure

# ...

$f->("everybody");
$g->("world");