help with regex in perl
Can someone help me get the correct regex for this string?
Total 14,928 3,967
I am trying to remove that line using this, but no luck:
shift @lines if $li开发者_如何学Cnes[0] =~ /^Total/;
Its also the last line of the output file.
What you might consider instead is:
@lines = grep !/^Total/, @lines;
If it is always the last line:
splice @lines, -1, 1 if $lines[-1] =~ /^Total/;
-1
is the last element in the array.
Or, more simply, as ikegami pointed out:
pop @lines if $lines[-1] =~ /^Total/;
精彩评论