Why do I have to use a * in front of a Perl bareword filehandle?

后端 未结 3 1549
無奈伤痛
無奈伤痛 2020-12-16 03:05

While trying to do this:

 my $obj = new JavaScript::Minifier;
 $obj->minify(*STDIN, *STDOUT);
// modified above line to
 $obj->minify(*IP_HANDLE,*OP_HA         


        
3条回答
  •  無奈伤痛
    2020-12-16 03:44

    It's the glob sigil. *FOO refers to the glob named "FOO", just like $FOO refers to the scalar named "FOO", and so forth. Globs are usually code references or filehandles.

    You need the sigil present in order to modify a glob value, eg *name_of_sub = sub{};, or to take its value without invoking special syntax, eg of calling a sub.

提交回复
热议问题