in reply to extracting a filename from an ls -Rla

Assuming that $ftp->ls() acts as its commandline cousin, just don't use l as an argument.
It stands for 'long' and gives you all the details you don't want.

You also might not want the a either, as it lists 'hidden' files, that depends on the context of your application.

As a second note, instead of the if(...){...} blocks you can write shorter
$ftp->doIt() || die("couldn't...");