Perl: What is the meaning of ;\$ inside the arg list of a sub declaration? -
here part of program generated s2p, program builds perl script performs particular sed
command.
# getsargv: read input line argument (default: $_). # move on next input file, , reset eof flag $iseof. sub getsargv(;\$){ $argref = @_ ? shift() : \$_; while( $iseof || ! defined( $$argref = <arg> ) ){ close( arg ); return 0 unless @argv; $file = shift( @argv ); open( arg, "<$file" ) || die( "$0: can't open $file reading ($!)\n" ); $iseof = 0; } 1; }
i couldn't find explains sub signature on perlsub.
the code work quite well, too.
it's prototype. particular prototype forces parser accept usages
getsargv()
and
getsargv($scalar)
and causes them compiled as
&getsargv()
and
&getsargv(\$scalar)
Comments
Post a Comment