First, please read
How do I post a question effectively?. In particular, please wrap code in
<code> tags so that we can be sure your content doesn't get mangled. I'll be working with
my $ex = QA::STK::Execute->new(ip=>'some ip',user=>'root');
$ex->command("ls-l");
my $rc = $ex->execute();
my $output = $ex->output();
I cannot find any reference to a module called QA::STK::Execute, but I will make assumptions based on syntax. If you review the
Basic debugging checklist, the first thing you should check is does
$output contain what you think it does.
printing is the easiest basic check. Given that you are running
ls-l in your posted code and not
ls -l (note the space), I'd bet you've got empty output.
Once you've verified that it seems reasonable, you can either use index as Corion suggested, or craft a regular expression. A regular expression has the advantage of anchoring to the end of a line, since you are looking for a file name. Maybe something like:
if (/\s\Q$xyz\E$/) {
# Code to run
}
The easiest way to deal with this is for you to post some example output from
ls -l and then what you tried in order to find the file's name, all wrapped in
<code> tags.
You will note that your lack of adherence to site expectations has garnered you down votes. Read the links, and see if they make sense. You can even edit your posts to fix them up.
#11929 First ask yourself `How would I do this without a computer?' Then have the computer do it the same way.