I am new to perl scripting. I want to write subroutine test to log file. for e.g.
my ($logfile, $logpath);
$logpath = /usr/bin ;
$logfile = "$logpath/log.txt";
open (LOG,">>","$logfile") || die ("Error : can t open log file");
sub test
{
print "Hi
";
my $date = `date`;
}
sub logFunc
{
print LOG "Writing log files
";
print LOG test(); # we cannot do like this :)
}
logFunc();
Say their are 15+ subroutines. So to write commands in each subroutine to log file I have to write print LOG "[Command] "; which works fine but script length is huge. So using common subroutine is their any way to achieve this?