Open
Description
Where
perldoc perlsub / man perlsub.
Description
Because the intent of this feature is primarily to let you define
subroutines that work like built-in functions, here are prototypes for
some other functions that parse almost exactly like the corresponding
built-in.
Declared as Called as
sub mylink ($$) mylink $old, $new
sub myvec ($$$) myvec $var, $offset, 1
sub myindex ($$;$) myindex &getstring, "substr"
sub mysyswrite ($$$;$) mysyswrite $buf, 0, length($buf) - $off, $off
sub myreverse (@) myreverse $x, $y, $z
sub myjoin ($@) myjoin ":", $x, $y, $z
sub mypop (\@) mypop @array
sub mysplice (\@$$@) mysplice @array, 0, 2, @pushme
sub mykeys (\[%@]) mykeys $hashref->%*
sub myopen (*;$) myopen HANDLE, $name
sub mypipe (**) mypipe READHANDLE, WRITEHANDLE
sub mygrep (&@) mygrep { /foo/ } $x, $y, $z
sub myrand (;$) myrand 42
sub mytime () mytime
This must be from a very old version where syswrite could only write to STDOUT ... it takes a filehandle now.
And for me, it happily accepts two args ... fh and $buf.
Gemini backs the page up, saying that it does not need the glob prototype, because the file handle is presumably already declared. He is probably righht, but if it was opened in another module, I would expect weeping and wailing if you didn't give it *STDOUT.
Also, myopen is not entirely like open, but I seem to recall reading elsewhere that open can't really be emulated by mere mortals. but you can do open(my $pipe,"-|",qw( echo this is a command )); myopen can't handle that.