Re: looping through a file

2007-05-09 Thread Chas Owens
On 5/9/07, Rob Dixon <[EMAIL PROTECTED]> wrote: Steve Bertrand wrote: >> but if they appear in the file in a different sequence then you also >> need to rewind and start looking at the beginning of the file once >> again like this: >> >> ID: >> foreach my $prime_id ( @id_hits ) { >>while (

Re: looping through a file

2007-05-09 Thread Rob Dixon
Steve Bertrand wrote: but if they appear in the file in a different sequence then you also need to rewind and start looking at the beginning of the file once again like this: ID: foreach my $prime_id ( @id_hits ) { while ( my $line = <$AFILE> ) { if ( $line =~ /$prime_id/ ) { pr

Re: looping through a file

2007-05-09 Thread Steve Bertrand
> but if they appear in the file in a different sequence then you also > need to rewind and start looking at the beginning of the file once > again like this: > > ID: > foreach my $prime_id ( @id_hits ) { >while ( my $line = <$AFILE> ) { > if ( $line =~ /$prime_id/ ) { >print "

Re: looping through a file

2007-05-08 Thread Robert Hicks
Rob Dixon wrote: Robert Hicks wrote: I decided to back up a bit and try a more simple routine. I have the array @id_hits populated and I can search the log for the line and print it. The problem is it only finds the first match and that is it. foreach my $prime_id ( @id_hits ) { while ( m

Re: looping through a file

2007-05-08 Thread Rob Dixon
Jeff Pang wrote: -Original Message- From: [EMAIL PROTECTED] Sent: May 8, 2007 9:54 PM To: [EMAIL PROTECTED] Cc: beginners@perl.org Subject: Re: looping through a file my @lines = <$AFILE>; foreach my $prime_id ( @id_hits ) { foreach my $line( @lines ) { if (

Re: looping through a file

2007-05-08 Thread Rob Dixon
Robert Hicks wrote: I decided to back up a bit and try a more simple routine. I have the array @id_hits populated and I can search the log for the line and print it. The problem is it only finds the first match and that is it. foreach my $prime_id ( @id_hits ) { while ( my $line = <$AFILE>

Re: looping through a file

2007-05-08 Thread Jeff Pang
-Original Message- >From: [EMAIL PROTECTED] >Sent: May 8, 2007 9:54 PM >To: [EMAIL PROTECTED] >Cc: beginners@perl.org >Subject: Re: looping through a file >my @lines = <$AFILE>; >foreach my $prime_id ( @id_hits ) { > foreach my $line( @lines ) { >

Re: looping through a file

2007-05-08 Thread yaron
> To: beginners@perl.org Sent: Tuesday, May 8, 2007 4:39:12 PM (GMT+0200) Auto-Detected Subject: Re: looping through a file I decided to back up a bit and try a more simple routine. I have the array @id_hits populated and I can search the log for the line and print it. The problem is it only f

Re: looping through a file

2007-05-08 Thread Robert Hicks
I decided to back up a bit and try a more simple routine. I have the array @id_hits populated and I can search the log for the line and print it. The problem is it only finds the first match and that is it. foreach my $prime_id ( @id_hits ) { while ( my $line = <$AFILE> ) { if ( $li

Re: looping through a file

2007-05-08 Thread Dr.Ruud
Robert Hicks schreef: > open my $IFILE, '<', $IDFILE || die "Could not open $IDFILE: $!"; This doesn't mean what you assume it does. It is a mix up of: open(my $IFILE, '<', $IDFILE) || die "Could not open $IDFILE: $!"; and open my $IFILE, '<', $IDFILE or die "Could not open $IDFILE: $!";

RE: looping through a file

2007-05-07 Thread Craig Schneider
Hi Guys Following is a log file extract which I desperately need to covert to coma separated for an entire logile called access.log (squid proxy log) for reporting purposes. There has been some internet surfing abuse on a client's network. 1178606984.937 1 192.168.1.55 TCP_DENIED/407 1904 PO

Re: looping through a file

2007-05-07 Thread Robert Hicks
Chas Owens wrote: On 5/7/07, Robert Hicks <[EMAIL PROTECTED]> wrote: snip I think part of the problem is the 'shift'ing that I was doing. I am looking into that. Basically I was shift'ing the @log out of existence after the first pass. snip That sounds like a viable candidate for the warning a

Re: looping through a file

2007-05-07 Thread Chas Owens
On 5/7/07, Robert Hicks <[EMAIL PROTECTED]> wrote: snip I think part of the problem is the 'shift'ing that I was doing. I am looking into that. Basically I was shift'ing the @log out of existence after the first pass. snip That sounds like a viable candidate for the warning as well. snip > A

Re: looping through a file

2007-05-07 Thread Robert Hicks
Chas Owens wrote: On 5/7/07, Robert Hicks <[EMAIL PROTECTED]> wrote: I have one file that contains a log. I do a substr to get the information out of that and push it into an array. I have a second file that contain another log. I need to loop through the items in the array and find them in thi

Re: looping through a file

2007-05-07 Thread Chas Owens
On 5/7/07, Robert Hicks <[EMAIL PROTECTED]> wrote: I have one file that contains a log. I do a substr to get the information out of that and push it into an array. I have a second file that contain another log. I need to loop through the items in the array and find them in this log. Once I find