Thanks Ichi, you are correct but before that I need to verify that the string is separated by /t or not. so for that I have to use regular expression. I am using below code but it returns only /proj in $1.

No, actually there are multiple string formats available in file and one of them what I have given so I have to match the string before doing anything. The regular expression usage would be mandatory in my case.

If there is no space in both of string and separator is space then below working fine but problem arise when space is there in either or both strings. The second string might not be available but if it is available then should be separated by space.

my $my_re1 = '(?: (\/\w\S+))'; my $my_re2 = '(?:\s+(\/\w\S+))';

$match = $my_re1 . $my_re2 . '{0,1}'

Now I want to support above functionality with having space in either or both string and separated by tab.

please start using the code tags to post code and samples of data, that way spaces and tabs are preserved in the display making it much easier to see what you are trying to explain. -------------------------------------------------