A
adamomitcheney
Hi there Perl gurus,
I'm using (trying to use) a regexp to extract a path and a comment from
the output of a 'describe' command in clearcase. I suspect I'm being
daft, so please go easy on me... I have read what I think is the
appropriate perldoc (perldoc -q greedy - "What does it mean that
regexes are greedy? How can I get around it? greedy greediness"), but
I'm already doing what it suggests - that is, reducing the greediness
of the '.+' expression with a '?'. I guess I must have missed
something..
The input ($hl) should look something like this:
->
M:\adam_admin\eq-gla_playpen\eq-cc-gla_playpen\testforccase\TestTwo.PRM@@
"This is the to-text"
I'm trying to get at the path and the comment:
if ($hl =~ m%^[->|<-]%)
{
$hl =~ s%^[->|<-] (.+?)@@ "(.+?)"%$1%;
$comment = $2;
}
else
{
$hl = 0;
}
print "Target is $hl\n";
print "Comment is \"$comment\"\n";
Produces the following output:
Target is ->
M:\adam_admin\eq-gla_playpen\eq-cc-gla_playpen\testforccase\TestTwo.PRM@@
"This is the to-text"
Comment is ""
I've also tried escaping the '@@' thus '\@\@' but that hasn't made any
difference.
I realise I could probably use split to do this and then substitute out
the -> or <-, but I'm quite keen to understand what I'm doing wrong.
Cheers - Adam...
I'm using (trying to use) a regexp to extract a path and a comment from
the output of a 'describe' command in clearcase. I suspect I'm being
daft, so please go easy on me... I have read what I think is the
appropriate perldoc (perldoc -q greedy - "What does it mean that
regexes are greedy? How can I get around it? greedy greediness"), but
I'm already doing what it suggests - that is, reducing the greediness
of the '.+' expression with a '?'. I guess I must have missed
something..
The input ($hl) should look something like this:
->
M:\adam_admin\eq-gla_playpen\eq-cc-gla_playpen\testforccase\TestTwo.PRM@@
"This is the to-text"
I'm trying to get at the path and the comment:
if ($hl =~ m%^[->|<-]%)
{
$hl =~ s%^[->|<-] (.+?)@@ "(.+?)"%$1%;
$comment = $2;
}
else
{
$hl = 0;
}
print "Target is $hl\n";
print "Comment is \"$comment\"\n";
Produces the following output:
Target is ->
M:\adam_admin\eq-gla_playpen\eq-cc-gla_playpen\testforccase\TestTwo.PRM@@
"This is the to-text"
Comment is ""
I've also tried escaping the '@@' thus '\@\@' but that hasn't made any
difference.
I realise I could probably use split to do this and then substitute out
the -> or <-, but I'm quite keen to understand what I'm doing wrong.
Cheers - Adam...