Is there any way to check whether a file (attached in a workflow) is locked or not (using Perl)
Yes. Refer to your version of TeamSite Command-Line Tools manual.