Re: What am I doing wrong?!
From: Jürgen Exner (jurgenex_at_hotmail.com)
Date: 10/29/03
- Next message: Ben Morrow: "Re: [OT] DOS window."
- Previous message: dave the spazz: "job: perl script for authorize.net AIM (advanced integration method)"
- In reply to: Tony Walker: "What am I doing wrong?!"
- Next in thread: Tore Aursand: "Re: What am I doing wrong?!"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Wed, 29 Oct 2003 16:47:31 GMT
Tony Walker wrote:
> OK, what I'm doing is a basic search of a logfile for specific
> strings. At present I have this working fine by manually creating an
> array and foreaching it..
> However, I now want to read these strings from a file and perform the
> same actions as before but I'm hitting a problem. I slurp the file
> into and array and it only ever finds ONE of the strings in the file,
> not the other!!
>
> Any help much appreciated..
>
> Tony
>
> p.s this is my first attempt at perl so it may not look great...
> ##
> #!/opt/perl/bin/perl
> open (ER,"ALL_errors") or die "$!";
> my @entry = <ER>;
I wager you forgot to chomp() here.
> open (LOG,"all.log") or die "$!";
> while (<LOG>){
> my $CUR=$_;
> for (my $i=0;$i<=$#entry;$i++) {
Och, that's C, not Perl:
for (my $i=0..@entry)
Or use just
for (@entry)
> my $LINE = @entry[$i];
> if ($CUR =~/$LINE/){
and then here
if ($CUR =~/$_/){
instead fo the two lines above
> print $CUR;
> }
> }
> }
> ####
- Next message: Ben Morrow: "Re: [OT] DOS window."
- Previous message: dave the spazz: "job: perl script for authorize.net AIM (advanced integration method)"
- In reply to: Tony Walker: "What am I doing wrong?!"
- Next in thread: Tore Aursand: "Re: What am I doing wrong?!"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|
|