open(PASSWD, '/etc/passwd'); while (<PASSWD>) { chomp; ($login, $passwd, $uid, $gid,$gcos, $home, $shell) = split(/:/); #... }
What exactly is the first line doing? The while is reading through the file at the directory /etc/passwd ?
For my purposes would I write
open READINGFILE, "data.txt" or die $!; open LOGFILE, ">>logfile.txt" or die $!; while (<READINGFILE>) { chomp; ($domain, $IP) = split(/,/); if ($ip_obj->{src_ip} eq $IP){ print LOGFILE $domain; print LOGFILE " has been found"; } }
Right now I'm getting errors:
Global symbol "$domain" requires explicit package name at test.pl line + 113. Global symbol "$IP" requires explicit package name at test.pl line 113 +. Global symbol "$IP" requires explicit package name at test.pl line 114 +. Global symbol "$domain" requires explicit package name at test.pl line + 115. BEGIN not safe after errors--compilation aborted at test.pl line 235 ( +#1) (F) You've said "use strict" or "use strict vars", which indicates that all variables must either be lexically scoped (using "my" or +"state"), declared beforehand using "our", or explicitly qualified to say which package the global variable is in (using "::"). Uncaught exception from user code: Global symbol "$domain" requires explicit package name at test +.pl line 1 13. Global symbol "$IP" requires explicit package name at test.pl line 113 +. Global symbol "$IP" requires explicit package name at test.pl line 114 +. Global symbol "$domain" requires explicit package name at test.pl line + 115. BEGIN not safe after errors--compilation aborted at test.pl line 235. at test.pl line 235
What am I missing?
And yes I have several files at various steps in the process to make sure I don't take steps backwards, thanks for the advice though and the link is a good reference but I need it a little more... dumbed down for me to understand. lol.
In reply to Re^2: To Split or Not to Split
by burningredmoon
in thread To Split or Not to Split
by burningredmoon
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |