perl script to replace values in a file

rag84dec's Avatar, Join Date: Jul 2007
Go4Expert Member
Hi all,
I need a perl program to do the following...

I have a File with some values...the file has following values in different lines...

device1
path1
FileName1

I need to write these values in a file in a proper place...
Like in place of "Device" i need to replace it with "device1"
In place of "Path" i need to replace it with "path1"...etc...

Can anyone help me in writing a perl code?
pradeep's Avatar, Join Date: Apr 2005
Team Leader
Code: Perl
my @data;
open(H,'yourFile.txt') or die $!;
while( my $line = <H>)
{
 push(@data,lc $line);
}

close H;
open(H,'>yourFile.txt') or die $!;
print H join("\n",@data);
close H;