Hi Eyal, On Friday 21 Jan 2011 15:55:58 אייל ב. wrote: > Hi Shlomi, Again. > I'm sorry for keep sending you mails (It's because my answers to the > to the group still doesn't work and I sent a complaint to > postmas...@perl.org) > > I hope now when I use a plain text message, it will be more understandable. > (BTW, now it will use the ">" ? I really not have much experience in > netiquette rules)
See: * http://en.wikipedia.org/wiki/Posting_style * http://www.caliburn.nl/topposting.html [snipped personal stuff] > Back to Perl, and to my script. > Because there are many things to understand, I want to focus on my > major problem why, following the variable I took from the Regular Ex.: > $list. > I don't know why this is working : print $list{125} ; > But this ain't working : print $list{$line} ; while there is 125 on the > %line. What can be the difference. (I tried chomp) ? > I tried to debug, I still can't understand why it's doesn't work ! What does x $line and x \%list say inside the debugger. > > (BTW, I understood the bareword issue, and implement it , according to > your recommendations. Got a new errors : > Global symbol "$machine_IP" requires explicit package name at > C:\system\Perl\OS- recognize\os-rec5.01_.pl line 14. > Global symbol "$machine_IP" requires explicit package name at > C:\system\Perl\OS- recognize\os-rec5.01_.pl line 15. > Global symbol "$handle" requires explicit package name at > C:\system\Perl\OS-reco gnize\os-rec5.01_.pl line 32. That means you have not declared your variables. Read the thread here: http://www.nntp.perl.org/group/perl.beginners/2007/07/msg93172.html > Execution of C:\system\Perl\OS-recognize\os-rec5.01_.pl aborted due ..... > > Here is the new code: > > [code] > > #! C:\Perl\bin\perl > use strict; > use warnings; > > my %list = > (60=>"linux",61=>"linux",62=>"linux",63=>"linux",64=>"linux",65=>"linux", > 125=>"Windows",126=>"Windows",127=>"Windows",128=>"Windows", > 250=>"Unix",251=>"Unix",252=>"Unix",253=>"Unix",254=>"Unix",255=>"Unix", > 256=>"Unix",257=>"Unix",258=>"Unix",259=>"Unix",260=>"Unix"); > > my $path = "c:/system/Perl/hosts.txt" ; > # read an IP List from the txt file c:/system/Perl/BSO2.txt and take > the TTL data to the variable: $line > open my $machines_fh, '<', $path > or die "Could not open '$path' - $!"; > while (my $machine_ip = <$machines_fh>) { Well, the indentation here is wrong, so it's hard to read. This seems like an artefact of an indentation preserving mode while pasting without a special reservation for preserving indentation. Regards, Shlomi Fish -- ----------------------------------------------------------------- Shlomi Fish http://www.shlomifish.org/ Optimising Code for Speed - http://shlom.in/optimise Chuck Norris can make the statement "This statement is false" a true one. Please reply to list if it's a mailing list post - http://shlom.in/reply . -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/