How can I combine two patterns in Perl

Viewed 97

I would like to merge these 2 regexp in one next if $line =~ /^#/ or $line =~ /^\d+\-\d+/;

1 Answers

"or" is easy: use the alternation |:

next if $line =~ /^#|^\d+-\d+/

You can even factor ^ out:

/^(?:#|\d+-\d+)/
Related