in reply to Need help with script with a while loop reading file
Hi brianjb,
I know your question has been probably answered :).
However, if I may draw your attention to some stuff in your code:
- this
would fail to do what you intended, in case your file doesn't exists.open FILE, "<hostname_check.txt" || die $!;
It's better written as
oropen ( FILE, "<hostname_check.txt" ) || die $!;open FILE, "<hostname_check.txt" or die $!; - Use lexically scoped filehanles and the 3-argument open function like so:open my $fh, '<',"hostname_check.txt" or die $!;
- Also check the return of close function
If you tell me, I'll forget.
If you show me, I'll remember.
if you involve me, I'll understand.
--- Author unknown to me
If you show me, I'll remember.
if you involve me, I'll understand.
--- Author unknown to me
|
---|
In Section
Seekers of Perl Wisdom