if you run "which dir" instead of "dir /archive/myfile", what do you get from 1) perl script and 2) direct on command line on the remote machine? My first guess is that when invoked under perl it might not be processing .login (or similar) so your path or alias settings are different... Also try putting a full path to dir like "/usr/bin/dir /archive/myfile"
Also consider (not saying it's necessary, but might help with this or future tasks)