Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: Need help with script with a while loop reading file

by 2teez (Priest)
on May 03, 2013 at 16:23 UTC ( #1031924=note: print w/ replies, xml ) Need Help??


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
    open FILE, "<hostname_check.txt" || die $!;
    would fail to do what you intended, in case your file doesn't exists.
    It's better written as
    open ( FILE, "<hostname_check.txt" ) || die $!;
    or
    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


Comment on Re: Need help with script with a while loop reading file
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1031924]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (9)
As of 2014-07-28 11:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (196 votes), past polls