R. Joseph Newton wrote:
>
> "Dennis G. Wicks" wrote:
>
> > Greetings;
> >
> > I have a file that I need to sort and currently I am just
> > sorting it by
> >
> >       @datalist = sort(@datalist);
>
> Try this:
>
> >       @articles = sort {substr($a, 6) + 0 <=> substr($b, 6) + 0}
> > @files;
> >
> > but I can't figure out how to tell the sort that $a and $b
> > are the first six characters of @datalist. That is numeric
> > data BTW.

Hi Joseph.

That's

  substr STRING, OFFSET, LENGTH

also the TIE-fighter will force it's parameters to numeric,
so there's no need to add zero.

so it'll be:

  sort {substr($a, 0, 6) <=> substr($b, 0, 6)} @files;

Rob



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


Reply via email to