Mega Code Archive

 
Categories / Perl / Statement
 

Use while loop to read console input and replace

while (<>) {    for (split) {        s/m/y/g;        print;    } } while ($_ = <>) {    for $_ (split / /, $_) {        $_ =~ s/m/y/g;        print $_;    } }