my ($ar, $x, $y, $vr, $fps);
creates new variables through each pass of the loop.
Dump [$ar, $x, $y, $vr, $fps] if /^$/;
only prints on the passes where the input is a blank line. When $_ is a blank line, the other if conditions are false, so the variables don't get popupulated.
One solution is to read a paragraph at a time.
local $/ = ''; # Paragraph mode. while (<DATA>) { my ($ar) = m|(\d+) kb/s|; my ($x, $y, $vr, $fps) = m|(\d+)x(\d+).*(?:(\d+) kb/s.*)?(\d+\.\d+) + fps|; Dump [$ar, $x, $y, $vr, $fps]; }
Update: Since the data is rather variable, the following might be more reliable. I also added a fix to ignore 0x12345678.
local $/ = ''; # Paragraph mode. while (<DATA>) { my ($ar ) = m|Audio.*?(\d+) kb/s|; my ($x, $y) = m|(?!0)(\d+)x(\d+)|; my ($vr ) = m|Video.*?(\d+) kb/s|; my ($fps ) = m|(\d+(?:\.\d+)?) fps|; Dump [$ar, $x, $y, $vr, $fps]; }
In reply to Re: conditional regex
by ikegami
in thread conditional regex
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |