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

David Christensen dpchrist at holgerdanske.com
Sun Feb 1 17:31:40 PST 2026


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!




More information about the SanFrancisco-pm mailing list