Skip to content

Instantly share code, notes, and snippets.

@shinchit
Created September 3, 2014 08:56
Show Gist options
  • Save shinchit/9fbe7f289115e638a924 to your computer and use it in GitHub Desktop.
Save shinchit/9fbe7f289115e638a924 to your computer and use it in GitHub Desktop.
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