And Green has asked for the wisdom of the Perl Monks concerning the following question:

Hallowed Monks,

I'm attempting to pattern match a clearcase environment variable: $ENV{CLEARCASE_VIEW_TAG}

This gives the view tag at the time a trigger is fired.

If the match I am looking for is in $dir = "this is result"

then the pattern $dir =~ m/result/ provides a match.

But if the value of $ENV{CLEARCASE_VIEW_TAG} is result and I try and match it:

$dir =~ m/$ENV{CLEARCASE_VIEW_TAG}/ for example or use a scalar containing $ENV{CLEARCASE_VIEW_TAG} for the match instead, it does not match.

Even tried printing the value of $ENV{CLEARCASE_VIEW_TAG} before the match is attempted and it should match.

Any ideas as to why it does'nt?

Thanks in advance

  • Comment on Trying to pattern match a clearcase environment variable

Replies are listed 'Best First'.
Re: Trying to pattern match a clearcase environment variable
by moritz (Cardinal) on Sep 17, 2008 at 12:14 UTC
    I can't reproduce your problem:
    #!/usr/bin/perl use strict; use warnings; $ENV{CLEARCASE_VIEW_TAG} = 'result'; if ("i can haz result" =~ $ENV{CLEARCASE_VIEW_TAG}) { print "match\n"; } __END__ match

    So chances are that one of the variables doesn't contain what you think it does. Try to use Data::Dumper to find out. Be sure to set $Data::Dumper::Useqq = 1 before using it, that way non-printable characters will also be shown.

Re: Trying to pattern match a clearcase environment variable
by Anonymous Monk on Sep 17, 2008 at 12:15 UTC