On Sat, 9 Nov 2013 16:27:24 +0200
Shlomi Fish <shlo...@shlomifish.org> wrote:

> #!/usr/bin/perl
> 
> use strict;
> use warnings;
> 
> my $sub_ref = sub { return time() + 30 };
> 
> print "Sub-ref call is: ", scalar( $sub_ref->() ), "\n";

Why not just use a sub?

sub time_delay {
    my $delay = shift @_;

    return time() + $delay;
}

The only time you would need a sub reference would be if it is a
callback sub for a module not written by your company.


-- 
Don't stop where the ink does.
        Shawn

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to