Aug 22, 2008 #1 sedawk Programmer Feb 5, 2002 247 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 Apr 2, 2004 960 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 Jan 21, 2005 5,070 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!