Re: need help on perl code
- From: paikkos@xxxxxxxxxxxxxx (Dermot)
- Date: Tue, 16 Jun 2009 21:27:28 +0100
2009/6/16 Irfan Sayed <irfan_sayed2002@xxxxxxxxx>:
Hi All,
Hello,
I have perl script like this :
use strict;
use warnings;
use Cwd;
my $chver;
my $fina;
&chversion();
&chversion() should be kept as simply chversion();
sub chversion {
print STDERR "Current directory is " . cwd() . "\n";
print "Reading version file\n";
open (VER2, "<", 'D:\hudson\workspace\RTU_Trunk_Build_Official\Trunk\versions.txt') or die "Couldn't open versions.txt for reading: $!\n";
while (<VER2>) {
$chver=$_;
}
print "$chver\n";
open (VER1, "+>", 'D:\hudson\workspace\RTU_Trunk_Build_Official\Trunk\Metrino\MonitoringSystem\Rtu\RtuInstallKit\EXFO RTU System\EXFO RTU System') or die "Couldn't open versions.txt for read/write: $!\n";
print "Hi\n";
I think you have a error in the open/while loop. According to
perlopentut (#Mixing Reads and Writes) the command is
open(SCREEN, "+> /tmp/lkscreen")
|| die "can't open /tmp/lkscreen: $!";
I suspect that your opened the file to write/append and then slurping
it in a while loop but it's not opened in the correct mode so there is
nothing coming in. So rather than using the 3 argument open, you want
the 2 argument as above.
while (<VER1>) {
print "HI\n";
if ($_ =~ m/"OutputFilename"/) {
print "Match found\n";
$fina =~ s/$_/{.*}$chver.msi/;
}
}
print "$fina\n";
close VER1;
}
This is just my opinion, I haven't tested anything :-0
Dp.
.
- References:
- need help on perl code
- From: Irfan Sayed
- need help on perl code
- Prev by Date: AW: need help on perl codebeginners@perl.org
- Next by Date: Exception error in perl code
- Previous by thread: AW: need help on perl codebeginners@perl.org
- Next by thread: Exception error in perl code
- Index(es):