1. We have moved from vBulletin to XenForo and you are viewing the site in the middle of the move. Though the functional aspect of everything is working fine, we are still working on other changes including the new design on Xenforo.
    Dismiss Notice

perl script to replace values in a file

Discussion in 'Perl' started by rag84dec, Dec 3, 2008.

  1. rag84dec

    rag84dec New 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...


    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?
  2. pradeep

    pradeep Team Leader

    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;

Share This Page