Snippet Name: Call subroutine and pass filehandle
Description: Call a subroutine and pass a filehandle. Perl's typeglob comes to the rescue. The special * ("star") type symbol allows you to refer to filehandles as if they were scalars.
Comment: (none)
Language: PERL
Highlight Mode: PERL
Last Modified: March 06th, 2009
|
OPEN XM, "/path/to/some/file.txt";
print_file(*XM);
SUB print_file {
MY $handle = SHIFT;
WHILE (<$handle>) {PRINT};
}
|