Erwin Zavala wrote: > My export.txt file has data in the format > > Joe Doe mail: [EMAIL PROTECTED] > > I want my script to replace mail for email. At the end of the script > I get an empty file? Why what am i doing wrong > > #!/user/bin/perl > > open(openFile, "<export.txt"); > open(writeFile, ">export.txt");
Opening a file for write mode truncates it to zero length. So at this point, export.txt is now empty. The while loop below will not execute, since the first read from openFile will return undef (EOF). You need to write to a *different* file. See the FAQ article: perldoc -q 'chage one line' > while(<openFile>) > { > print writeFile if s/mail/email/ ; > } -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]