Michael Alipio wrote:
> Hi Mumia,

It's John but hello anyway.

> I think this one is closer to my goal.
> 
> #!/usr/local/bin/perl
> use warnings;
> use strict;
> 
> my $logfile='fortilog';
> my $devicefile='deviceid';
> our %clientdevice;
> 
> open DEVICES, '<', $devicefile or die "Can't open $devicefile $!";
> 
> while (<DEVICES>){
>   (my $client) = $_ =~ /^(\S+\s+)/;
>   (my $device) = $_ =~ /(\S+)$/;
>   $clientdevice{$device} = $client;
> }
> close DEVICES;
> 
> 
> open( LOGFILE, '<', $logfile ) or die "Can't open $logfile: $!";
>  while(my $log = <LOGFILE> ){
>   (my $deviceid) = $log =~ /device_id=(\S+?),/;
>   if (exists $clientdevice{$deviceid}){
>      open FH, '>>', $clientdevice($deviceid) or die $!;

Change the parentheses () to braces {} there:

      open FH, '>>', $clientdevice{$deviceid} or die $!;

>      print FH $log;
>      close FH;
>    }
> }
> 
> The "if exist" line keeps on complaining:

It is actually the line after that one that has the problem.

> Variable "$clientdevice" is not imported at extractdevice.pl line 23.
> Global symbol "$clientdevice" requires explicit package name at 
> extractdevice.pl line 23.
> syntax error at extractdevice.pl line 23, near "$clientdevice("

Line 23 is:

>      open FH, '>>', $clientdevice($deviceid) or die $!;



John
-- 
Perl isn't a toolbox, but a small machine shop where you can special-order
certain sorts of tools at low cost and in short order.       -- Larry Wall

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to