Shift Question
- From: davidlamontadams@xxxxxxxxx (Dave Adams)
- Date: Tue, 27 Sep 2005 17:16:35 -0400
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);
.
- Follow-Ups:
- Re: Shift Question
- From: Chris Devers
- Re: Shift Question
- Prev by Date: Re: PERL's equivalent to an "include file"
- Next by Date: Block Confusion
- Previous by thread: how to use perl modules
- Next by thread: Re: Shift Question
- Index(es):
Relevant Pages
|