> Why don't I Get IP addresses in the IP Address column of the report 
below.  The data is there if I do a print after the split of the value 
in %GAA_Up


foreach $GS_IPAddr (keys(%GAA_Up)) {
           open (UP, ">>$GS_Report") || die "Could not open file 
$GS_Report : $!\n";
          ($GS_Location,$GS_IPAddr,$GS_Time)=split(/\t/,$GAA_Up{$GS_IPAddr 
});
         write(UP);
         close(UP);
 }

I imagine (depending upon you data) you're running into a lexical scoping 
problem.  For one thing its *not* a good idea to use $GS_IPAddr as both 
your loop key and an assigned to var from the split.  Its confusing and 
unnecessary and buys you nothing (but, maybe the cost of one scalar).

However, there's a little magic in how perl handles foreach loop vars as 
far as scoping goes and when you're using it to work w/ a format ... good 
luck. Or here, bad luck.  Adding warnings to your script and the crucial 
part is (line 40 is the UP format line):

Use of uninitialized value in formline at /tmp/form.pl line 40.
Use of uninitialized value in formline at /tmp/form.pl line 40.
Use of uninitialized value in formline at /tmp/form.pl line 40.

Because you don't scope the other split vars, they become global and just 
(luckily) get attached to the format as you wanted them. But $GS_IPAddr is 
scoped as the foreach loop var and so isn't global enough to make the 
grade.  It doesn't exist outside those curlies and so - no IP for you!

Strict/warnings - its not just a good idea, its a Best Practice - which is 
close enough to being a law ;->

a

Andy Bach
Systems Mangler
Internet: [EMAIL PROTECTED]
VOICE: (608) 261-5738  FAX 264-5932

"So it goes ...."
Kurt Vonnegut, Jr. (November 11, 1922 ? April 11, 2007) 
_______________________________________________
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to