我正在尝试读取文件,然后想在while
循环外打印输出。有没有办法做到这一点?
这就是我正在做的事情:
my $booklistFile= file.txt;
my $perlbook;
my $javabook;
my $cbook;
my $data;
open my $booklist, "<", $booklistFile or die "can not open the file";
my %bookHash = ();
while(<$booklist>)
{
($perlbook, $javabook, $cbook) = split (',');
$bookHash{$cbook} = $cbook;
$data = $bookHash{$cbook} ;
print $data;
}
这将打印循环$data
内部。while
有没有办法可以在循环$data
外打印?while