Bryan Irvine wrote:
> 
> [EMAIL PROTECTED] wrote:
> > 
> > Assuming there is only one set of brackets on a line, and you only
> > want the IP address between them, and READLOG is an open handle to
> > your log:
> >
> > - Not Tested -
> > my @ips;
> > while (my $line = <READLOG>) {
> >    if ($line =~ /\[(.*)\]/) {
> >       push @ips, $1;
> >    }
> >    else {
> >       print STDERR "no ip in line\n";
> >    }
> > }
> > print "@ips\n";
> 
> I don't mean to sound stupid, but uhhhh *scratch-scratch* what's a
> READLOG open handle? ;-)

A open (file) handle is what you get when you successfully open() or
sysopen() a file.

perldoc -f open
perldoc -f sysopen
perldoc perlopentut


> I have about 7500+ messages in a spam folder on the mail server (in
> Maildir) and I'm trying top parse them out.
> 
> Here's my stupid script so far:
> 
> #!/usr/bin/perl

You should use warnings and strict to let perl help you find obvious
mistakes.


> @fileList = `ls -1`;

You should use opendir/readdir/closedir or glob to get the list of
files.


> $filecount = "5";

You don't have to quote numbers.


> #$makeIPList = `cat @fileList[$filecount]`;
                      ^
                      ^
> @fileList[$filecount] =~ s/\]/\[/g;
  ^
  ^
> @getIP = `grep Received\: @fileList[$filecount]`;
                            ^
                            ^
If you had warnings enabled then perl would have told you that using an
array slice in these situations is probably not what you want.  Are you
sure that the sixth file in @fileList is always going to be the one you
want?  You should probably use perl's built-in grep function instead of
shelling out to use an external command.


> [EMAIL PROTECTED] =~ s/\]/\[/g;
> 
> @split = split (/\[/, $getIP);

The scalar $getIP and the array @getIP are two different variables so
you are trying to split a variable with nothing in it.


> print "getIP----  @getIP\n";
> print "filelist-  @fileList[filecount]\n";
                    ^
                    ^


John
-- 
use Perl;
program
fulfillment

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to