Ls command to get selection only without hierarchy


I have a script that creates a joint on a piece of geometry, and then I want to do some other things to it.
The problem I’m running into right now is the ls script is selecting the entire path of the current selection, and that’s causing confusion in the rest of the script.

Here is an example:

This script:

string $sel[] = `ls -sl`;

Is returning the following result:

// Result: pCube2|pCube3 //

When I need it to only return “pCube3”, which is the last thing that I selected. Can anyone point me as to what I’m doing wrong?