in reply to can't replace a directory with a variable

Try this:

$OLEControl->{Document}->write("<html><body><img src = '$file' /></body></html>"); # Write Html

Using double quotes " instead of single ones ' you tell perl to interpolate the variable reference inside the string.

Or, better, use sprintf:

$OLEControl->{Document}->write(sprintf('<html><body><img src = "%s" /></body></html>',$file)); # Write Html

that gives you more control on how the string is built.

Rule One: "Do not act incautiously when confronting a little bald wrinkly smiling man."