Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Subroutine prototype

Status
Not open for further replies.

sedawk

Programmer
Feb 5, 2002
247
US
What does the ";$" in the following subroutine prototyping?

Code:
sub doIt(;$) {
    use strict;
    my $src = @_ ? : shift : "";
    ....
}
 
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.)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top