hi all,
i am still not able to modify existing lines in the existing file.
here is my code
plz help

use strict;
use warnings;
use Cwd;
my $chver;
my $fina;
my @lines;
&chversion();
sub chversion {
  print STDERR "Current directory is " . cwd() . "\n";
  print "Reading version file\n";
open (VER, "<", '.\versions.txt') or die "Couldn't open versions.txt for 
reading: $!\n";
while (<VER>) {
 chomp($chver=$_);
}
 close VER;
open (FILE, "<", '.\Metrino\MonitoringSystem\Rtu\RtuInstallKit\EXFO RTU 
System\EXFO RTU System.vdproj') or die "Couldn't open for reading: $!\n";
open (OUT, ">", '.\Metrino\MonitoringSystem\Rtu\RtuInstallKit\EXFO RTU 
System\EXFO RTU System.vdproj') or die "Couldn't open for writing: $!\n";
      print "$chver\n";
while (<FILE>) {
  
    if ($_ =~ m/"OutputFilename"/) {
    $_ =~ s/(\d*.\d*.\d*).msi/$chver.msi/;
    print OUT "$_\n";
   }
  
 
}
close FILE;
}




________________________________
From: Irfan Sayed <irfan_sayed2...@yahoo.com>
To: "beginners@perl.org" <beginners@perl.org>
Sent: Wednesday, June 17, 2009 4:02:47 PM
Subject: Re: file handle in perl


thanks all




________________________________
From: Ajay Kumar <ajay.kum...@synopsys.com>
To: Irfan Sayed <irfan_sayed2...@yahoo.com>
Cc: "beginners@perl.org" <beginners@perl.org>
Sent: Wednesday, June 17, 2009 3:42:41 PM
Subject: RE: file handle in perl

Hi Irfan
You can do all four task like below

1: open FILE ,">filename.txt" or die$!;
2: my @lines=<FILE>
3: do changes through sed
        Like sed -e 's/original pattern/new pattern/p' filename
4:if you did changes it automatically get saved
5: close(FILE);

Thanks
Ajay



-----Original Message-----
From: Irfan Sayed [mailto:irfan_sayed2...@yahoo.com]
Sent: Wednesday, June 17, 2009 2:42 PM
To: beginners@perl.org
Subject: file handle in perl

Hi All,

I am struggling with file handling in perl. i want to do following operation .

1: open the file
2: read the file
3: do the changes in specific lines
4: save the file
5: close the file

i am not getting which operand i should use to do this operation . i tried all 
operands like >, >>, <, +<, +>

please advice

here is the line which i am using to open the file

open (FILE, "+<", '.\Metrino\MonitoringSystem\Rtu\RtuInstallKit\EXFO RTU 
System\EXFO RTU System.vdproj') or die "Couldn't open for reading: $!\n";

plz plz advic

regards
Irf




--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


      

Reply via email to