Hi monks,

I cannot trace why all my captured vars come back undef because the debugger steps not finegrained enough. Where do I need to fix my code?

Also, how can I express it in regex that the captured var for e.g. $vr stays undef if there is no video bitrate, yet X/Y resolution and FPS are populated (because they are always on the line)?

Is that a job for regex anyway or is it more elegant with other tools? If yes, what do you recommend?

#!perl use strict; use diagnostics; use Data::Dump::Streamer; while (<DATA>) { my ($ar, $x, $y, $vr, $fps); ($ar) = (m|(\d+) kb/s|) if /Stream.*Audio/; ($x, $y, $vr, $fps) = (m|(\d+)x(\d+).*(\d+) kb/s.*(\d+\.\d+) fps|) + if /Stream.*Video/; Dump [$ar, $x, $y, $vr, $fps] if /^$/; }; __DATA__ E:\jyb.avi Stream #0.1: Audio: mp3, 44100 Hz, mono, 80 kb/s Stream #0.0: Video: mpeg4, yuv420p, 464x240, 25.00 fps(r) E:\weit.m4v Stream #0.0(eng): Audio: aac, 44100 Hz, stereo Stream #0.1(eng): Video: h264, yuv420p, 320x240, 15.00 fps(r) E:\otm.mov Stream #0.1(eng): Audio: qdm2, 44100 Hz, stereo Stream #0.0(eng): Video: svq3, yuv420p, 320x240, 24.00 fps(r) E:\bo.mp4 Stream #0.1(eng): Audio: aac, 44100 Hz, stereo Stream #0.0(eng): Video: mpeg4, yuv420p, 320x240, 25.00 fps(r) E:\tom.mpeg Stream #0.1[0x1c0]: Audio: mp2, 44100 Hz, stereo, 256 kb/s Stream #0.0[0x1e0]: Video: mpeg1video, yuv420p, 352x240, 1180 kb/s, +29.97 fps(r) E:\gb.rmvb Stream #0.1: Audio: cook, 44100 Hz, stereo, 44 kb/s Stream #0.0: Video: RV40 / 0x30345652, 352x288, 180 kb/s, 12.00 fps( +r) E:\xt.wmv Stream #0.0: Audio: wmav2, 32000 Hz, stereo, 32 kb/s Stream #0.1: Video: wmv1, yuv420p, 320x240, 15.00 fps(r)

In reply to conditional regex by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.