Hello all,
I am writing a script that (in part) opens a file for reading and writing, loops through the file line by line looking for a specific strings. If it finds any of the strings I want to delete the line and go to the next line in the file (while loop).
Here is what I have so far:
Here is what @excludes contains:
First, how do I delete the whole line that is in $_ from the while loop? Second, after deleting the line, how do I jump directly to the next line in the while loop without going throuh the rest of my @excludes array as if ANY of the $entry exist in the line I am going to delete it so I do not need to loop through the rest (hope that explains it ok).
Thanks,
Nick
If at first you don't succeed, don't try skydiving.
I am writing a script that (in part) opens a file for reading and writing, loops through the file line by line looking for a specific strings. If it finds any of the strings I want to delete the line and go to the next line in the file (while loop).
Here is what I have so far:
Code:
my ($profile,$server,$xfer_method,$path2log,$source,$site,$trak,$exclude) = split;
my @excludes = split (/,/,$exclude);
open (EXCLUDE, "+>$log_name")or ErrorOut ("Error opening log file $log_name: $1");
while (<EXCLUDE>) {
foreach my $entry(@excludes) {
if ($_ =~ $entry) {
delete the whole line here and go to the next line
}
}
Here is what @excludes contains:
Code:
.exe,.js,.ico,.gif,.jpg,.css,170.6.91.240,170.6.116.233,63.66.113.77
First, how do I delete the whole line that is in $_ from the while loop? Second, after deleting the line, how do I jump directly to the next line in the while loop without going throuh the rest of my @excludes array as if ANY of the $entry exist in the line I am going to delete it so I do not need to loop through the rest (hope that explains it ok).
Thanks,
Nick
If at first you don't succeed, don't try skydiving.