Changes

Jump to navigation Jump to search
170 bytes added ,  16:26, 28 December 2013
Line 475: Line 475:  
     logger("We have a logger subroutine!");
 
     logger("We have a logger subroutine!");
   −
What's that shift? Well, the arguments to a subroutine are available to us as a special array called @_ (see perlvar for more on that). The default argument to the shift function just happens to be @_ . So my $logmessage = shift; shifts the first item off the list of arguments and assigns it to $logmessage .
+
What's that '''[http://perldoc.perl.org/functions/shift.html shift]'''? Well, the arguments to a subroutine are available to us as a special array called '''@_''' (see [http://perldoc.perl.org/perlvar.html perlvar] for more on that). The default argument to the '''[http://perldoc.perl.org/functions/shift.html shift]''' function just happens to be '''@_''' . So '''my $logmessage = shift;''' shifts the first item off the list of arguments and assigns it to '''$logmessage''' .
    
We can manipulate @_ in other ways too:
 
We can manipulate @_ in other ways too:
Line 495: Line 495:     
For more information on writing subroutines, see [http://perldoc.perl.org/perlsub.html perlsub].
 
For more information on writing subroutines, see [http://perldoc.perl.org/perlsub.html perlsub].
 +
 
=== OO Perl ===
 
=== OO Perl ===
  

Navigation menu