New radio PIDs, more than 8 characters - "solved"

Ralph Corderoy ralph at inputplus.co.uk
Wed Aug 16 05:15:21 PDT 2017


Hi C. E.,

> So, yielding to your superior knowledge of PERL, for the sake of
> clarity for the benefit of those who may have had difficulty in
> following the nuances of the argument, or been confused by the
> multiple suggestions, would we both agree with?:
> 	\b[bpw][0-9][a-z0-9]{7,13}\b

I think it's

    \b[bpw]\d[b-df-hj-np-tv-z\d]{6,13}\b

to cover the existing ones that are eight long, up to the 15-long
w172vg029mkl852 that Vangelis mentioned.  And we may as well borrow from
the specification and cut out the vowels rather than allow a-z.

I'd probably put all of it other than the two `\b' into a variable with
qr//, and then embed that in regexps as needed, adding `()', or `\b',
etc., back.

Out of interest, I've looked at 3.01's get_iplayer for "]0" to see how
it already uses it.

     941         if ( $this->{pid} !~ m{^([pb]0[a-z0-9]{6})$} ) {

$1 doesn't seem to be used afterwards, so the `()' aren't needed.

    3359         if ( $prog->{pid} =~ m{^http.+\/([pb]0[a-z0-9]{6})\/?.*$} ) {

The `/' are unnecessarily backslashed given that m{} is used so the `/'
doesn't have special meaning.  The `.+' means the last thing to match
the PID RE is used.  The `/?' makes the terminating slash optional, but
this means "http://.../p0abc123def" matches, but $1 ignores the "def".
The `.*$' isn't wanted as it's always true.

    4409                 $pid = $1 if $prog->{pid} =~ /\/([bp]0[a-z0-9]{6})/

This time the first PID-like thing would be used.  Again, a "def" would
be ignored.

    4416         if ( $pid !~ /^[bp]0[a-z0-9]{6}$/ ) {
    4521         if ( $pid !~ /^[bp]0[a-z0-9]{6}$/ && $pid !~ /^http/ ) {
    4531                 if ( $pid =~ /^[bp]0[a-z0-9]{6}$/ ) {
    4603                         if ( $pid =~ /^[bp]0[a-z0-9]{6}$/ ) {
    4686         } elsif ( $prog->{pid} =~ /^[bp]0[a-z0-9]{6}$/ ) {

All the same.  Fine.

    5095         if ( $prog->{pid} !~ m{^([pb]0[a-z0-9]{6})$} ) {

"pb" rather than "bp", just for spice.  No need to capture.

    5253         return $1 if $_[0] =~ m{/?([wpb]0[a-z0-9]{6})};

This one has a `w'!

-- 
Cheers, Ralph.
https://plus.google.com/+RalphCorderoy



More information about the get_iplayer mailing list