in reply to "if" to "case ... end"

Without you specifying in more detail how expr1,expr2,expr3 are to be plugged into your CASE...END statements, I can only offer this

while(<>){ if( /IF\(expr1,expr2,expr3\)/ ) { if( rand() > 0.1 ) { s/IF\(expr1,expr2,expr3\)/CASE\nWHEN condition THEN result +\n[ WHEN condition THEN result ]...\n[ ELSE result ]\nEND\n/; } else { s/IF\(expr1,expr2,expr3\)/CASE expression\nWHEN value THEN + result\n[ WHEN value THEN result ]...\n[ ELSE result ]\nEND\n/; } } }