All Pages All Books|
|
||||
|
$rs = generate_greeting("hello");
# Instead of invoking it as $&rs(), give it your own name.
*greet = $rs;
greet(); # Equivalent to calling $&rs(). Prints "hello world\n"
Of course, you can also similarly give a name to other types of references.
3.3.4 References to Typeglobs
We have seen how references and typeglobs are equivalent (in the sense that references can be assigned to typeglobs). Perl also allows you to take references to typeglobs by prefixing it with a backslash as usual:
$ra = \*a;
References to typeglobs are not used much in practice, because it is very efficient to pass typeglobs around directly. This is similar to the case of ordinary scalars, which don't need references to pass them around for efficiency.
|
||||
|
|
||||
|
Previous: 3.2 Typeglobs
|
Advanced Perl Programming
|
|||
|
|
||||
|
3.2 Typeglobs
|
Book Index
|
3.4 Filehandles, Directory Handles, and Formats
|
||
|
|
||||
|
|
||||
All Pages All Books