The word starts with -D (it may also be -d).
Followed by zero or more spaces.
After that it’s followed by a $.
Then the series is {rajna_NAME}.
To be brief
-d ${ranjana_wdgf_NAME}or -D${Tom_task_NAME}
I want to extract
ranjana_wdgf
Tom_task
My doubt is
if ( $word =~ m/^-D(\$)\|(\w*NAME)\b/)
What’s wrong?
Sometimes regexes are not as robust as other means.
For this case, I wouldn’t mind giving
Text::Balanceda try.