On 20 January 2011 15:38, Eyal B. <ewinst...@gmail.com> wrote: > I'm writing a scripts that check the TTL of the ping and found the OS. > According the TTL - the script should let me know which OS it is : > Linux/ Windows or Unix (Hash table) > > I'm getting an error on the line where I should use the TTL variable - > and take the right value from the hash (%list) :Use of uninitialized > value in print at D:\system\perl\os-rec\os-rec5_.pl line 24 > , <HANDLE> line 3. > > Any idea ? > if("$line" =~ "TTL=") > { > $line =~ s/.*TTL=//; > print "TTL = $line\n"; > print $list{"$line"} ; > # print "Machine $machine_IP is $list{$line}" ; > last; }
Assuming a specific line is made of nothing but TTL=, then $line =~ s/.*TTL=//; will erase the line, leaving you with an empty (uninitialized) $line variable. A way to debug this will be to include a print $line just before the substitution, so you could find what is happening in each stage of the iteration. -- Erez La perfection soit atteinte non quand il n'ya plus rien à ajouter, mais quand il n'ya plus rien à retrancher. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/