for ($i=0;$i<=$SIZE;$i++) {
$_=$LINES[$i];
if (...........
need to know how to ask if a line contains <!--addsearch--> AND more than two " speech quotes
Hope you can help
Marko
for ($i=0;$i<=$SIZE;$i++) {
$_=$LINES[$i];
if (...........
need to know how to ask if a line contains <!--addsearch--> AND more than two " speech quotes
Hope you can help
Marko
Jump to PostHere you go...
use strict; use warnings; my @array=<DATA>; my $x; for (@array){ chomp; $x++; if(/\<\!\-\-addsearch\-\-\>/){ my @hold; my $count=(@hold)=$_=~/\"/g; if($count>=2){ print "yep line # $x: $_\n"; } } } __DATA__ <html> <body> a line <br> another" with one quote <!--addsearch--> yet one more "and another" <!--addsearch--> …
Here you go...
use strict;
use warnings;
my @array=<DATA>;
my $x;
for (@array){
chomp;
$x++;
if(/\<\!\-\-addsearch\-\-\>/){
my @hold;
my $count=(@hold)=$_=~/\"/g;
if($count>=2){
print "yep line # $x: $_\n";
}
}
}
__DATA__
<html>
<body>
a line <br>
another" with one quote <!--addsearch-->
yet one more
"and another" <!--addsearch-->
not this one
<!--addsearch--> "hi"
</body>
</html>
just noticed that lines 9 & 10 can be replaced with:
my $count=()=$_=~/\"/g;
and not use the hold array. Gotta love perl
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.