Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?

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 $!;
    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

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1031924]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (5)
As of 2018-01-24 03:59 GMT
Find Nodes?
    Voting Booth?
    How did you see in the new year?

    Results (255 votes). Check out past polls.