Ksh errors while copying a directory

Hello all,

I have a ksh script run on Solaris 10 by the root user. The section that's giving me errors is the following:

VAR=$(perl -lne '...')

if [[ "$VAR" == "" ]] ; then
print "$VAR undefined"
fi

recover_files {
print "Recovering the files..."
cd ${VAR}/files
cp -pr nfs /destination
print "Files recovered"
}

$VAR is correctly defined (I don't see the error message displayed), however, when reaching the recover_files function, I have the following errors:

....
Recovering the files...
./my_script.sh[3]: */files: not found
cp: cannot access nfs
...

On a second run of the script, no error is displayed anymore, and the nfs directory is copied to the destination.
The "cannot access" error tells me that I was trying the cp from a wrong location, but I can't really figure out the first error - can someone help?

Thank you,
Adrian

As posted the script contains syntax errors which may be masked by other oddities in the script such as misplaced quotes or brackets. We really need to know what the perl program puts into $VAR. As posted it is a syntax error because the program name is missing. Somehow $VAR="*" at the time of the "cd".

I believe that this construct is invalid.

There are two syntaxes for functions in ksh.

subroutine1 ()
{
ls -la
}
# Execute subroutine1
subroutine1
#
function subroutine2 {
ls -la
}
# Execute subroutine2
subroutine2