I am looking at ClearCase triggers written in Perl. I noticed that in some regular expressions, variables are passed either straighforwardly, or their names are in braces.
For example, I have the following line of code in a trigger:
if ($baseline !~ /^${component}_(|.*_)$phase\.\d+(|[az]|-\d+|${automateddigit})$/ && $baseline !~ /^${project_root}_$phase\.\d+(|[az]|-\d+|${automateddigit})$/)
$component , $phase , $automateddigit , $project_root are all variables.
Why are some passed as $variable and others passed as ${variable} in the regular expression?
Does this come from how they are initialized?
Here is the line of code that initializes them:
($project = $ENV{CLEARCASE_PROJECT}) =~ s/\@.*$//; ($component = $ENV{CLEARCASE_COMPONENT}) =~ s/\@.*$//; ($project_root, $phase) = ($project =~ /^(.*)_(R\d+.*)$/); exit(0) if (! $phase); $phase .= ".0" if ($phase =~ /^R\d+$/); $automateddigit = ''; $istream = `cleartool desc -fmt "%[istream]p" project:$ENV{CLEARCASE_PROJECT}`; $componentlist = `cleartool desc -fmt "%[components]Cp" stream:$ENV{CLEARCASE_STREAM}`; $componentsnbr = split(',', $componentlist); if ($componentsnbr > 1) { $automateddigit .= '\\.\\d+'; }
syntax regex clearcase perl triggers
Thomas corriol
source share