あまりperlを書かない自分のための備忘録
boiler.pl
#!/usr/bin/perl
use strict;
use Sys::Hostname;
my %time;
my %hostname;
&getTime(\%time);
&getHostname(\%hostname);
sub getTime (\%) {
my $time = shift;
my ($sec, $min, $hour, $day, $month, $year, $mday) = (localtime(time))[0,1,2,3,4,5,6];
$$time{'year'} = $year + 1900;
$$time{'month'} = sprintf("%02d",$month + 1);
$$time{'day'} = sprintf("%02d",$day);
$$time{'hour'} = sprintf("%02d",$hour);
$$time{'min'} = sprintf("%02d",$min);
$$time{'sec'} = sprintf("%02d",$sec);
}
sub getHostname (\%) {
my $hostname = $_[0];
$$hostname{'fqdn'} = hostname();
$$hostname{'short'} = (split(/\./,$hostname{'fqdn'}))[0];
}