Re: Any suggestions?

From: David Warren (davidw_spam_at_spam_gto.net)
Date: 10/20/04


Date: Wed, 20 Oct 2004 02:58:25 -0400

Jim Gibson wrote:
> In article <weCdnYecxoKj_ejcRVn-gw@golden.net>, David Warren
> <davidw_spam@spam_gto.net> wrote:
>
>
>> Frame# 8575/8575 192 kbps L R "
>>

> I am assuming you have 'use strict' and 'use warnings' at the
> beginning of your program.

Yes I'm using 'use strict' and 'use warnings'

>
>> my ( @nums , $num ); local $/ = "\r"; open PIPE, "lame $args
>> \"$song_source\" \"$song_destin\" 2>&1 |"; my $y =
>> $e->gauge_start( text => "Converting: $song_source", percentage =>
>> 1 ); my $line_count = 1;
>>
>> then I'm using a while loop:
>>
>> while ( <PIPE> ) { if ( /Frame/ && /kbps/ && /$line_count/ ) {
>
>
> Here you are trying to match the input line against the current value
> of $line_count. Why are you doing that? The line you show above
> doesn't have a line count value in it. This test will succeed
> randomly based on whether or not the actual line has the current
> value of $line_count in it as a substring somewhere.
>

Perhaps $line_count would be better defined as $frame_count. There is
no real reason other than trying to ensure the output is filtered.
On the 2 and 3rd lines of output from LAME it outputs a
filename and I was just trying to ensure it would be filtered out. (given
that there is some wierd filenames out there). Perhaps, not neccessary or
maybe there would be a better way, to make sure I just got the last line
of output ( which is updated/buffered ) from LAME.

The portion that updates is:

Frame# --->8575<---/8575 192 kbps L R "
That could range anywhere from 1105 -> 8575 (lame skips the first 1105
frames). In this examples, depends on size of mp3.

> You can test and extract the number you want from the input line in
> one operation:
>
> if( |Frame#\s*\d+/(\d+)| ) { my $num = $1; # do something with $num }
>
>
>

>> $line_count++; unless ( defined($num) ) {
>
>
> Why are you testing to see if $num is defined? This will result in
> only performing the extraction one time, since you are assigning a
> value to $num below.
>

Here I'm after only:

Frame# 8575/-->8575<-- 192 kbps L R

This never updates, and I don't need to try to match against it anymore
once I defined $num. Thought it would be unneccessary and pointless to
try and continue to try and match against it. Is there any differences in
efficency between checking if a variables is defined or using pattern
matching?

> Then you should clean it up before asking hundreds of people for
> help. If you need more help, please post a complete, working, minimal
> program that shows the problem you are having.
>
> Thanks.

I should rephrase, I am trying to clean it up. Partially that is what I
was looking for here. Next time I will include a small working
example and being a little clearer. Trying to learn how to use regex
(yes I've read docs) (NOTE - my version was working, I was looking for a
cleaner/more efficent way of doing the while loop.)

Thanks for the help.

David



Relevant Pages

  • Re: loading, Flipping and saving jpgs
    ... Public Shared Function FromFile(ByVal filename As String, ByVal useEmbeddedColorManagement As Boolean) As Image ... Dim num As Integer ... Dim zero As IntPtr = IntPtr.Zero ...
    (microsoft.public.vb.general.discussion)
  • Re: hta file refresh output in textarea
    ... >displays status messages in a scrolling textarea. ... > copy filename to destination ... > individual files) the updates appear in the text area. ... Set WSHShell = CreateObject ...
    (microsoft.public.scripting.vbscript)
  • [PATCH 2.6.9-bk7] Select cpio_list or source directory for initramfs image updates [u]
    ... Here is some updates after talking to Sam Ravnborg. ... +# or set CONFIG_INITRAMFS_SOURCE to another filename or directory. ... +# 'missing' if $/$/$.shipped is missing ...
    (Linux-Kernel)
  • Re: Drive and full path in name at top of screen
    ... You're solution works well and updates as you do which is ... Mervyn ... > the actual filename for "filename") ... > The above will display and print the drive; full path; and the Tab. ...
    (microsoft.public.excel.misc)
  • cannot run MSCONFIG - (want to remove startup processes)
    ... I am using Windows 2000 (sp4), have latest updates. ... "Cannot find the file 'MSCONFIG'. ... Make sure the path and filename are correct and that all required libraries are available." ...
    (microsoft.public.win2000.setup)

Loading