QUESTION: What is the purpose of the line "my $msg = shift;"? I am
guessing it is for the @_ array but what list element is there to be
shifted off? It seems that the shift function is in a lot of
subroutines and I am confused as to their purpose.
#!/bin/perl -w
(my $PROGNAME = $0) =~ s/^.*\///;
(my $SHORT_PROGNAME = $PROGNAME) =~ s/\.pl$//;
my $SYSLOG_PRIORITY = 'info';
my $SYSLOG_FACILITY = 'local4';
use Sys::Syslog;
sub write_log($) {
# write a datestamped message to the logfile, e.g.:
# &write_log('some message');
my $msg = shift;
# print message to logfile:
openlog($SHORT_PROGNAME,'pid','');
syslog("$SYSLOG_FACILITY|$SYSLOG_PRIORITY", '%s', "$msg");
closelog();
}
$teststring = 'Test Msg to SysLog';
write_log($teststring);
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>