[sf-perl] Perl 5 script "future" revision 1.2

Richard Reina gatorreina at gmail.com
Sun Feb 1 17:53:46 PST 2026


What exactly is this code supposed to do?


> 
> On Feb 1, 2026, at 7:32 PM, David Christensen <dpchrist at holgerdanske.com> wrote:
> 
> Everyone:
> 
> Thank you for the discussion on Zoom today regarding my Perl 5 script "future".  Below please find an updated revision.
> 
> 
> David
> 
> --
> 
> 
> 2026-02-01 17:28:57 root at laalaa ~/sandbox/perl
> # cat future
> #!/usr/env/perl
> # $Id: future,v 1.2 2026/02/02 01:26:20 dpchrist Exp $
> # By David Paul Christensen dpchrist at holgerdanske.com
> # Public Domain
> 
> use strict;
> use warnings;
> 
> package Future;
> 
> sub new
> {
>    my $class = shift;
>    my $rc = shift;
>    return bless(sub {return $rc->(@_)}, $class);
> }
> 
> package main;
> 
> use Test::More;
> 
> our $FutureClass = "Future";
> 
> our $v = 'hello, world!';
> 
> sub future(&)
> {
>    my $rc = shift;
>    return bless(sub {return $rc->(@_)}, $FutureClass);
> }
> 
> my $f = Future->new(sub { $v });
> my $g = future { $v };
> 
> print $f->(), $/;
> print $g->(), $/;
> 
> {
>    local $v = 'goodbye, cruel world!';
>    print $f->(), $/;
>    print $g->(), $/;
> }
> 
> print $f->(), $/;
> print $g->(), $/;
> 
> 
> 
> 2026-02-01 17:28:59 root at laalaa ~/sandbox/perl
> # perl future
> hello, world!
> hello, world!
> goodbye, cruel world!
> goodbye, cruel world!
> hello, world!
> hello, world!
> 
> 
> _______________________________________________
> SanFrancisco-pm mailing list
> SanFrancisco-pm at pm.org
> https://mail.pm.org/mailman/listinfo/sanfrancisco-pm


More information about the SanFrancisco-pm mailing list