in reply to discard lines after match
Now, the problem is that your program isn't doing anything useful with the data being read at this point. I would assume that you want to do something with the lines you are reading and that you don't filter out with your regexes, perhaps printing them to STDOUT or to a file, or possibly storing them in an array or something else for further processing.last if /^__DISCARD__/;
In addition, just one minor comment:
The .* and .? seem to be pointless here. You could have:next if $_ =~ /--.*/; next if $_ =~ /^SVSA.?/;
which would yield the same results (except that this second version might probably be slightly more efficient, but that would be hardly noticeable, even with large input). This is really secondary, but it seems to indicate some misunderstandings in the comprehension of how regexes work. So, you are discarding lines matching --, presumably because -- might indicate the beginning of a comment (it does in some programming languages), but if this is the case, you should do it only if the -- comes at the beginning of the line, so that you might prefer something like this:next if $_ =~ /--/; next if $_ =~ /^SVSA/;
or possiblynext if $_ =~ /^--/;
Similarly, discarding the "empty" lines might be better written:next if $_ =~ /^\s*--/; # also removing lines having -- with some lead +ing white spaces
next if $_ =~ /^\s*$/; # also removing lines with only white spaces
|
|---|