http://www.perlmonks.org?node_id=787249


in reply to Re: regex pattern match problem
in thread regex pattern match problem

Basically, you might consider something like this:
our $line='Your chemical info here...'; #BASICALLY, MAKE THE SUB DO WHATEVER YOU NEED #THEN PUT THE SUB IN THE REPLACEMENT SIDE OF #THE REGEX. my $ProcessMultiLine = sub { #START OF SUB my $templine = $line; my $temppart = ''; my $returnval = ''; while ($templine =~s/( YourMatchingRegexHere )//) { $temppart = $1; $temppart =~ s/ YourSubsMatch / YourSubsReplace /; $returnval .= $temppart; } #END WHILE return $returnval; } #END SUB $line =~ s/ MatchTheString / $ProcessMultiLine -> () /e;

Blessings,

~Polyglot~