Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
THRUST SERVICES & TOOLS
CLOUD EDITIONS
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Web CMS (TeamSite)
Extract DCR name in TPL (Perl)
sarahwright
Does anyone know how to extra the DCR name in the TPL? I want just the name, not the whole path. In Perl, I tried:
my $DCR = iwpt_get_dcr_name();
iwpt_output($DCR);
But this gives me the whole path, not just the name. I am no Perl expert so I'm having problems extracting out everything after the last slash. I thought maybe there was a parameter I could pass in to get the name only.
Thanks!
Find more posts tagged with
Comments
moonkhanna
use this
my $DCR = iwpt_get_dcr_name();
$DCR =~ s/.*?\/data\/(.*)/$1/;
If that does not work, then this
my $DCR = iwpt_get_dcr_name();
$DCR =~ s/.*?\\data\\(.*)/$1/;
sarahwright
The second option worked. Thank you so much!!
nipper
You can use basename, which is a perl module that is inefficient and slow, but easy. You can also use Regex.
something like
$DCR=~ m|(.*)/WORKAREA/(.[^/]+)/templatedata/([^/]+)/([^/]+)/data/(.*)$|;
$branch = $1;
$workarea = $2;
$cat = $3;
$type = $4;
$DCRName = $5;
This is untested, though I think I am close.
One caveat, this assumes that the DCR is in the data dir, it is a bit more complex if you have other dirs in between.