On Jan 21, 11:42 pm, ewinst...@gmail.com ("Eyal B.") wrote:
> On Jan 21, 4:30 pm, rob.di...@gmx.com (Rob Dixon) wrote:
>
>
>
> > On 21/01/2011 05:50, Erez Schatz wrote:
>
> > > On 20 January 2011 15:38, Eyal B.<ewinst...@gmail.com>  wrote:
>
> > >> 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;                                   }
> I found the issue, and resolve it
> This regex clean unnecessary, extra digits: $line =~/.*TTL=\s*(\S+)\s*$/;


> > > 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.
>
> > No it won't, it will leave $line containing a null (zero-length) string.
> > There is no way to change a string value to uninitialized (undef) by
> > deleting characters from it.
>
> > - Rob
>
> ok. So why on print "TTL = $line\n"; I do get TTL = 125, if it's
> undefined ?
> Thanks, Rob, for your answer.....


--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to