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