mmartin has asked for the wisdom of the Perl Monks concerning the following question:
<String name="changeTypeName">Modified</String>"
While looping through the array it finds the correct line, so the "if statement" is working correctly. But I can't seem to get the value of the REGEX match within the "if statement" to be assigned to the variable $changeType...?### The final result of this should be the string "Modified" from the +example line given above... for (my $x = 0; $x <= $#reportData; $x++) { if ($reportData[$x] =~ /^(\s+)(\<String name="changeTypeName"\>)/) { (my $changeType) = $reportData[$x] =~ /\>[A-z]+\</; # my $changeType = $reportData[$x] =~ /\>[A-z]+\</; # $reportData[$x] =~ /\>[A-z]+\</; # my $changeType = $reportData[$x]; # my $changeType = $1 if $reportData[$x] =~ /\>[A-z]+\</; print "Change Type is = $changeType\n"; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Assigning REGEX Match to a separate variable?
by choroba (Cardinal) on Apr 02, 2012 at 16:47 UTC | |
by mmartin (Monk) on Apr 02, 2012 at 16:54 UTC |