Assuming you mean between the first ENERGY and the last ENERGY,
while (<>) { if (/\bENERGY\b/) { ++$energy; if ($energy == 1) { $start = $.+1; } else { $end = $.; } } } say $energy; say $energy >= 2 ? $end-$start : 0;
In reply to Re: How to read lines between specific character
by ikegami
in thread How to read lines between specific character
by AG87
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |