in reply to read value from file won't pass if exists??

I tried it like this (i think you have a typo somewere), i noticed your file isn't colsed, and your hash is not readable:
However, this should work.
!/usr/bin/perl -w open MISS, "miss" or die "can't open $!"; my $miss=<MISS>; close MISS; my %clocks=( "10" => 0, "10.20.20.10" => 0, "10.20.47.13" => 0, "10.20.46.37" => 0, ); chomp $miss; # $miss="10.20.47.13"; print "$miss\n"; if (exists($clocks{$miss})){ print "Yup it's there\n"; }

Replies are listed 'Best First'.
Re^2: read value from file won't pass if exists??
by lcollins (Novice) on Jan 04, 2005 at 14:53 UTC
    I did not know I needed to close like that. Much to learn. thanks!
      In general, you don't need to call close yourself in a small script. Perl will close all open file handles when the script finishes. Additionally, if you open the same filehandle with a different file, Perl will close the first one for you first. If you're writing a large program, you can sometimes run into a limit on the total number of files you can have open at once, so it's a good habbit to close anything you have open when you're done with it, but it generally won't do any harm if you don't.