Category: >> Perl Code >> Call subroutine and pass filehandle Bookmark and Share

<< lastnext >>

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)

Author: CoderZone
Language: PERL
Highlight Mode: PERL
Last Modified: March 06th, 2009

open XM, "/path/to/some/file.txt";
sub print_file {
    my $handle = shift;
    while (<$handle>) {print};
There haven't been any comments added for this snippet yet. You may add one if you like.  Add a comment 
© | users online: 11