On 8/21/07, Jeff Pang <[EMAIL PROTECTED]> wrote:
>
>
> -----Original Message-----
> >From: Chas Owens <[EMAIL PROTECTED]>
> >Sent: Aug 21, 2007 10:01 PM
> >To: Jeff Pang <[EMAIL PROTECTED]>
> >Cc: [EMAIL PROTECTED], beginners@perl.org
> >Subject: Re: regex help
> >
> >On 8/21/07, Jeff Pang <[EMAIL PROTECTED]> wrote:
> >snip
> >> my @new = map { $_->[0] } sort { $b->[1] <=> $a->[1] or $b->[2] <=>
> >> $a->[2] or $b->[3] <=> $a->[3] } map { [ $_, split/\D+/ ] } @arr;
> >snip
> >
> >While splitting on non-number is a nifty solution, it would break if
> >the custom tag can contain a number (16-custom2.2-14).  It is better
> >to nail down the version number scheme and write a regex that pulls
> >the required info from it that throws an error if a version does not
> >match the scheme.
>
> Have you seen this case on his datas?

I have seen a sampling of his data; if that is all of the data he has
then he can sort it by hand and doesn't need Perl.  Experience has
taught me to expect the worst from data.  You need to be able to
detect (if not recover from) malformed data and your split /\D/ will
just silently do the wrong thing (well, there might be some undef
warnings if the version were "12.4").  GIGO* is fine for custom
crafted one liners, but production quality code should at least make
an attempt to notice if the data is bad and signal the user/admin.

* Garbage In/Garbage Out

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to