ceejay wrote:
> Robin Bowes;268261 Wrote:
>> You're patch will work, but this is probably better:
>>
>> if ($frameValue =~ /([^;]+)/) {
>> $frameValue = $1;
>> }
>>
>>
>> R.
>
> Thanks.
>
> Bearing in mind that my Perl skills are definitely at "beginner" level,
> could you comment on why your code is better? Is there some case I
> haven't thought of, are are you thinking of readability?
In practise, there is little difference. But, my version is a little
more efficient.
Here's yours:
$frameValue =~ s/;.*$//;
This matches the first semi-colon, followed by all other characters to
the end of the line. Actually, that's not strictly true since "."
doesn't match newlines (\n).
Here's mine (if you're sharp-eyed you'll notice I modified it slightly!):
if ($frameValue =~ /^([^;]+)/) {
$frameValue = $1;
}
This matches from the start of the string, capturing 1 or more
characters that are not semi-colons.
Consider a tag like this:
$frameValue = 'Rock;genre;genre;genre;genre;genre;genre;genre;genre';
Your regex would have to scan the whole string and match the last 48
characters then remove them.
Mine will only have to match the first four characters.
Like I said, in practise this would not be a major issue unless you were
doing this in a time-critical piece of code. But, since transcoding from
flac->mp3 is by far the task that takes the most time, this is merely an
exercise in good practise!
R.
_______________________________________________
ripping mailing list
[email protected]
http://lists.slimdevices.com/lists/listinfo/ripping