Aug 22, 2008 #1 sedawk Programmer Joined Feb 5, 2002 Messages 247 Location US What does the ";$" in the following subroutine prototyping? Code: sub doIt(;$) { use strict; my $src = @_ ? : shift : ""; .... }
What does the ";$" in the following subroutine prototyping? Code: sub doIt(;$) { use strict; my $src = @_ ? : shift : ""; .... }
Aug 22, 2008 #2 rharsh Technical User Joined Apr 2, 2004 Messages 960 Location US Everything before the semi-colon is required (in this case, there's nothing) everything after it is optional. So $src either gets set to whatever is passed to the sub or if nothing is passed in it's set to "" (rather than the default undef.) Upvote 0 Downvote
Everything before the semi-colon is required (in this case, there's nothing) everything after it is optional. So $src either gets set to whatever is passed to the sub or if nothing is passed in it's set to "" (rather than the default undef.)
Aug 22, 2008 #3 KevinADC Technical User Joined Jan 21, 2005 Messages 5,070 Location US More than you may ever want to know about prototypes: http://perldoc.perl.org/perlsub.html#Prototypes the semi-colon just seperates mandatory and optional arguments passed to the sub. ------------------------------------------ - Kevin, perl coder unexceptional! Upvote 0 Downvote
More than you may ever want to know about prototypes: http://perldoc.perl.org/perlsub.html#Prototypes the semi-colon just seperates mandatory and optional arguments passed to the sub. ------------------------------------------ - Kevin, perl coder unexceptional!