Perl: Greedy nature refuses to work

Posted by faezshingeri on Stack Overflow See other posts from Stack Overflow or by faezshingeri
Published on 2012-09-04T09:35:53Z Indexed on 2012/09/04 9:38 UTC
Read the original article Hit count: 158

Filed under:

I am trying to replace a string with another string, but the greedy nature doesn't seem to be working for me. Below is my code where "PERFORM GET-APLCY" is identified and replaced properly, but string "PERFORM GET-APLCY-SOI-CVG-WVR" and many other such strings are being replaced by the the replacement string for "PERFORM GET-APLCY".

s/PERFORM $func[$i]\.?/#  PERFORM $func[$i]\.\n $hash{$func[$i]}/g;

where the full stop is optional during string match and replacement. Please help me understand what the issue could be.

Thanks in advance, Faez

© Stack Overflow or respective owner

Related posts about perl