Created
September 3, 2014 08:56
-
-
Save shinchit/9fbe7f289115e638a924 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use strict; | |
use IO::File; | |
my $fh = new IO::File("somefile.txt", "r") || die "can't open file. $!¥n"; | |
# 引数としてファイルハンドル(実体はIO::Fileオブジェクト)を渡す | |
&some_process($fh); | |
sub some_process { | |
# ファイルハンドルの受け取り | |
my $passed_fh = shift; | |
# 一行取得 | |
my $line = $passed_fh->getline; | |
# 他にも通常のファイルハンドルを使うようにd$passed_fhを使ってごにょごにょできる | |
# : | |
# : | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment