The result of calling a particular shell command on my local system is the following:
azxinetgw.EXECFILE_DIR.azxinetgw='/usr/local/instinet/RTS/etc/local/az +xfiles'
I wrote the following Perl code to get the value part of the string (the part after the equal sign) using regexes even though split is easier so that I could practice my regexes. Here is my code, yet it does not work (in other words, printing $1 yields an empty string). So it is matching, but $1 is not bound. My regex is saying:
  1. match everything that is not an equal
  2. then match and equal
  3. then match a quote
  4. then match everything that is not a quote and save in $1
  5. then match another quote
But it doesn't seem to work:
sub get_assigned_dir { my $gpa_key = shift; my $gpa_ret = `$gpa $gpa_key`; warn $gpa_ret; if ( $gpa_ret =~ /[^=]+[=][']([^']+)[']/ ) { my $assigned_dir = $1 } else { die "couldn't determine assigned directory for $ +gpa_key" } log_msg "assigned dir for $gpa_key == $assigned_dir"; }

Also

Also would someone mind telling me why $1 simply has one 'a' in it in the second case?
$string = 'aaaaa'; print $1,$/ if $string =~ /(a)+/; print $1,$/ if $string =~ /(a+)/;

In reply to 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.