Reputation: 717
In Perl I'm trying to achieve this:
while ($row = <$fh>){
if the row contains the character >:
#do something AND then skip to the next line
else:
#continue to parse normally and do other things
Upvotes: 4
Views: 8564
Reputation: 4709
Try this way:
while ($row = <$fh>)
{
if($row =~ />/)
{
#do something AND then skip to the next line
next;
}
#continue to parse normally and do other things
}
Upvotes: 3
Reputation: 54323
You can skip to the next iteration of a loop with the next
built-in. Since you are reading line by line, that's all you need to do.
For checking if the character is present, use a regular expression. That's done with the m//
operator and =~
in Perl.
while ($row = <$fh>) {
if ( $row =~ m/>/ ) {
# do stuff ...
next;
}
# no need for else
# continue and do other stuff ...
}
Upvotes: 11