cleanup previous commit - use IO::File

This commit is contained in:
Dietmar Maurer 2014-05-17 09:07:18 +02:00
parent 15b21acc0d
commit 46f58b5f03

View File

@ -1126,15 +1126,15 @@ sub print_drivedevice_full {
} }
sub get_initiator_name { sub get_initiator_name {
my $initiator = undef; my $initiator;
open (FILE, '/etc/iscsi/initiatorname.iscsi') or return undef; my $fh = IO::File->new('/etc/iscsi/initiatorname.iscsi') || return undef;
while (<FILE>) { while (defined(my $line = <$fh>)) {
next unless m/^\s*InitiatorName\s*=\s*([\.\-:\w]+)/; next if $line !~ m/^\s*InitiatorName\s*=\s*([\.\-:\w]+)/;
$initiator = $1; $initiator = $1;
last; last;
} }
close FILE; $fh->close();
return $initiator; return $initiator;
} }