in reply to newbie questions on array access and control loops

*Assuming I understand the question any better or worse than anyone else*

May I ask why you are using a while(<FILE>) loop? It's going to set $_ to one line at a time, so setting an array to $_ isn't going to help you much...

You could try something like this:
my @filelines = <FILE>; #Read the entire file into an array my $whichline; #Declare a variable to hold the line number for(my $i = 0; $i = $#filelines; $i++){ #Go through the entire array +untill you find it or run out of lines if($filelines[$i] =~ m/TEXTTOMATCH/o){ #Attempt to match, use compi +le-once $whichline = $i; #If match, remember the line + and leave the loop. last; } }


Or if you want to find more than one line with that pattern:
my @filelines = <FILE>; #Read the entire file into an array my @whichline; #Declare a variable to hold the line number for(my $i = 0; $i = $#filelines; $i++){ #Go through the entire array +untill you find it or run out of lines if($filelines[$i] =~ m/TEXTTOMATCH/o){ #Attempt to match, use compi +le-once push(@whichline,$i); #If match, add to the list of current match +es } } #Now you know what lines had TEXTTOMATCH in them
Once you have the line with that, you can use splice() to remove the line if you wish, or do something else to it...

**Edit: Inserted comments in code and added multiple match**



"Weird things happen, get used to it."

Flame ~ Lead Programmer: GMS