#!/usr/bin/perl

use IO::Async::Loop;
use IO::Async::Signal;
use IO::Async::Timer::Periodic;

my $loop = IO::Async::Loop->new;
my $timer = IO::Async::Timer::Periodic->new(
	interval => 30,
	first_interval => 0,
	on_tick => \&take_pic,
);
$timer->start;
$loop->add($timer);
my $sighup = IO::Async::Signal->new(
   name => "HUP",
   on_receipt => \&take_pic,
);
$loop->add($sighup);
my $sigterm = IO::Async::Signal->new(
   name => "TERM",
   on_receipt => sub {
	   $loop->stop;
   },
);
$loop->add($sigterm);

$loop->run();

sub take_pic {
    my $epoch = time();
    system("/opt/vc/bin/raspistill -t 2000 -rot 270 -ex night -w -h -o ${epoch}cam.jpg");
}


#!/usr/bin/perl

use IO::Async::Loop;
use IO::Async::Signal;
use IO::Async::Timer::Periodic;

my %params = (
	'program' => '/opt/vc/bin/raspistill',
	'interval' => 30,
	'dealy' => 2000,
	'width' => 1024,
	'height' => 768,
	'rotation' => 270,
	'exposure' => 'night',
	'name' => 'cam.jpg',
);

my $command = $params{'program'} .
	' -t ' . $params{'delay'} .
	' -w ' . $params{'width'} .
	' -h ' . $params{'height'} .
	' -rot ' . $params{'rotation'} .
	' -ex '. $params{'exposure'} .
	' -o ';

my $loop = IO::Async::Loop->new;
#Timer
my $timer = IO::Async::Timer::Periodic->new(
	interval => $params{'interval'},
	first_interval => 0,
	on_tick => \&take_pic,
);
$timer->start;
$loop->add($timer);
#SIGHUP
my $sighup = IO::Async::Signal->new(
   name => "HUP",
   on_receipt => \&take_pic,
);
$loop->add($sighup);
#SIGTERM
my $sigterm = IO::Async::Signal->new(
   name => "TERM",
   on_receipt => sub {
	   $loop->stop;
   },
);
$loop->add($sigterm);
#run
$loop->run();
#subs
sub take_pic {
    my $epoch = time();
    my $final_command = $command . ' '. $epoch .'_'. $params{'name'};
    system($final_command);
}

Make parameters easier to change.
Make parameters easier to change.