-1

I have been looking at some Perl code that has some subroutine declarations that make no sense to me. They appear as:

foo($$$$;$);
foo(\$\$\$);

What do the symbols ";" and "\" do or mean in these declarations?

1 Answers1

5

They're "prototypes" - but Perl prototypes aren't like those in other languages, and probably shouldn't be used.

The $ denotes a scalar argument to the function. ;$ denotes an optional additional scalar argument. And \$ denotes a reference argument.

See also: Why are Perl 5's function prototypes bad?

Sinan Ünür
  • 116,958
  • 15
  • 196
  • 339
Sobrique
  • 52,974
  • 7
  • 60
  • 101