Why would one choose to declare and initialize a lexical variable in separate statements?

Viewed 435

This is an excerpt from AnyEvent::Intro

# register a read watcher
my $read_watcher; $read_watcher = AnyEvent->io (
    fh   => $fh,
    poll => "r",
    cb   => sub {
        my $len = sysread $fh, $response, 1024, length $response;

        if ($len <= 0) {
           # we are done, or an error occurred, lets ignore the latter
           undef $read_watcher; # no longer interested
           $cv->send ($response); # send results
        }
    },
);

Why does it use

my $read_watcher; $read_watcher = AnyEvent->io (...

instead of

my $read_watcher = AnyEvent->io (...

?

1 Answers
Related