>I just get tired of looking everything up in my Perl book.

Try perldoc ;)

$> perldoc chop
   chop VARIABLE
   chop LIST
   chop    Chops off the last character of a string and returns the
           character chopped. It's used primarily to remove the newline
           from the end of an input record, but is much more efficient than
           `s/\n//' because it neither scans nor copies the string. If
           VARIABLE is omitted, chops `$_'. Example:

>    local @fileList = reverse sort `ls $list*.list`;
>    local $current = chop $fileList[0];
>    local $previous = chop $fileList[1];
>

So your 
        $current = chop $fileList[0]; 
is probably doing the right thing, choping off the newline and returning it
to current.

>
>
>    local ($current,$previous) = (reverse sort `ls $list*.list`)[0,1];
>
>    chop $current;
>    chop $previous;
>Of course, I know there has to be a better way to do this:
>reverse sort `ls $list*.list`
>

my ($current, $previous) = (sort map { chomp; $_ } grep /$list.*\.list$/,
<*>)[1,0];


works, I think it does what you want (I used chomp instead of chop), but is
it better?  I guess that depends on your definition.  I got rid of the call
to reverse because I could do that with the slice, but it might not be as
readable and I have no idea how it does performance wise.

Have fun,
Peter C.

Reply via email to