in reply to SCP return code 256

Try maybe
my $scpcp = "scp -v $rfilewithpath $destdir"; ...
to get some debugging help and check STDOUT and STDERR afterwards. (You run this on a Unix or on a Windows platform ?...)

What exactly do you mean by saying "... when I run through scheduler..." ? Might be that you already have the debugging info somewhere, just need to find where it is written/appended to ...?