I tried to test this and it seems as though your regular expression is working fine. I had to make some small changes to test it and removed the single quotes on the second line ('$gpa $gpa_key') and replaced it with ($gpa_ret = "gpa: $gpa_key"). Otherwise, the value would not interpolate for the regex.
my $gpa_key = "azxinetgw.EXECFILE_DIR.azxinetgw='/usr/local/instinet/R +TS/etc/local/azxfiles'"; my $gpa_ret = "gpa: $gpa_key"; warn $gpa_ret; print "gpakey: $gpa_key\n"; #print "gparet: $gpa_ret\n"; if ( $gpa_ret =~ /[^=]+[=][']([^']+)[']/ ) { my $assigned_dir = $1 ; print "$assigned_dir\n";} else { die "couldn't determine assigned directory for $gpa_key" + }
By making this change, we are now passing the string instead of the literal name of the variable. You were actually testing the regex conditions on `$gpa $gpa_key` instead of the string value. The output from my modified version is:
gpa: azxinetgw.EXECFILE_DIR.azxinetgw='/usr/local/instinet/RTS/etc/loc +al/azxfiles' at D:\DATA_TO_MIGRATE\dbexamples\ex\gpa.pl line 7 . gpakey: azxinetgw.EXECFILE_DIR.azxinetgw='/usr/local/instinet/RTS/etc/ +local/azxfiles' /usr/local/instinet/RTS/etc/local/azxfiles

Mick

In reply to Re: Regular expression to match an A=B type string needs help in storing matched parts of string by mrmick
in thread Regular expression to match an A=B type string needs help in storing matched parts of string by princepawn

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.