Ok, I know I should know this by now, but I always get in a "chicken or the egg" logic loop here.
I am looking to write/steal a function that will take an array as input, then:
1) remove blank lines, and,
2) remove redundant (same) lines
So, if I had an array:
@arry1 = (
"This is line one",
"This is line two",
"This is line three",
" \n",
"\t\n",
"This is line one",
"This is line two",
"This is line three" );
and I then ran it through a function, say like this:
print condense(@arry1);
it would produce this result:
This is line one
This is line two
This is line three
my code looks like this, thus far:
sub condense {
my @done = ();
foreach (@_) {
if(tr/\S+//) { #if there is any number of non-whitespace characters...
push( @done, $_ ) if (@done =~ grep{/$_/} @done);
}
}
return @done;
}
My problem is I am trying to find a string $unvalidated in @good_strings.
Is this
I am looking to write/steal a function that will take an array as input, then:
1) remove blank lines, and,
2) remove redundant (same) lines
So, if I had an array:
@arry1 = (
"This is line one",
"This is line two",
"This is line three",
" \n",
"\t\n",
"This is line one",
"This is line two",
"This is line three" );
and I then ran it through a function, say like this:
print condense(@arry1);
it would produce this result:
This is line one
This is line two
This is line three
my code looks like this, thus far:
sub condense {
my @done = ();
foreach (@_) {
if(tr/\S+//) { #if there is any number of non-whitespace characters...
push( @done, $_ ) if (@done =~ grep{/$_/} @done);
}
}
return @done;
}
My problem is I am trying to find a string $unvalidated in @good_strings.
Is this