perl.beginners
[Top] [All Lists]

reg:file handling

Subject: reg:file handling
From: Gowri Chandra Sekhar Barla
Date: Sun, 16 Mar 2008 18:10:16 +0530
Newsgroups: perl.beginners
Hi

 

I am unable to modify the input file ,

 

If I am redirecting output to with different file name it working fine

 

 

In want to replace name in a file

 

Script: problem

 

print " Enter the file Name \n";

$filename = <STDIN>;

open(INPUT,"<$filename");

open(OUTPUT,">filename");

while(<INPUT>)

{

if($_ =~ s/FRCC/FRE/)

{

print OUTPUT "$_";

}

else

{

print OUTPUT "$_";

 

}

 

Script: No problem script working fine

 

print " Enter the file Name \n";

$filename = <STDIN>;

open(INPUT,"<$filename");

open(OUTPUT,">new1.c");

while(<INPUT>)

{

if($_ =~ s/FRCC/FRE/)

{

print OUTPUT "$_";

}

else

{

print OUTPUT "$_";

 

}

 

 

Please help me

 

 

Thanks and regards

Chandu

 



DISCLAIMER:
-----------------------------------------------------------------------------------------------------------------------

The contents of this e-mail and any attachment(s) are confidential and intended 
for the named recipient(s) only.
It shall not attach any liability on the originator or HCL or its affiliates. 
Any views or opinions presented in 
this email are solely those of the author and may not necessarily reflect the 
opinions of HCL or its affiliates.
Any form of reproduction, dissemination, copying, disclosure, modification, 
distribution and / or publication of 
this message without the prior written consent of the author of this e-mail is 
strictly prohibited. If you have
received this email in error please delete it and notify the sender 
immediately. Before opening any mail and 
attachments please check them for viruses and defect.

-----------------------------------------------------------------------------------------------------------------------
<Prev in Thread] Current Thread [Next in Thread>