Shift Question



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);
.



Relevant Pages

  • conditional index of arrays
    ... This following section is redundant across the subroutines, but I cannot figure out how put it into another subroutine and return the result in a way that I can use it. ... foreach { ... push(@}, $value); ... sub defindex { ...
    (perl.beginners)
  • Re: Can you pass a Property of a User Defined Object to a Sub ByRef and Update it?
    ... which defeats the purpose of the class. ... The private members *should not* ... Public Sub AddNewItem ... then s is a pointer to the Dictionary. ...
    (microsoft.public.scripting.vbscript)
  • Re: Prompt to enter a macro name?
    ... Sub testme ... Rick ... those old 123 macros and xlm macros as macros, ... macros are subroutines that do not any arguments; ...
    (microsoft.public.excel.programming)
  • Re: How to run VBA code on all rows of a table
    ... Private Sub SubName() ... put in ALL the code from all seven subroutines ... THEN how do I call the function in a query ...
    (microsoft.public.access.formscoding)
  • Re: I would like to display....
    ... Im not sure it serve my purpose. ... Members who are logged in to my site i whant to display on a list. ... >> Regards Mikael ... > sub session_onstart ...
    (microsoft.public.inetserver.asp.general)