On 8/24/07, Jeff Pang <[EMAIL PROTECTED]> wrote:
>
> 2007/8/24, Mihir Kamdar <[EMAIL PROTECTED]>:
>
> > $cdr[13] = $cdr[6]*5 ; ###Can I do something like this
>
> sure,why can't?
Hi,
Please look at my code below and comment. I am trying to manipulate 13th
field of my record. But I am not getting the desired result in the output.
The output file is the same as the input file.
#!/usr/bin/perl
use warnings ;
my $file_path =
'/home/user71/RangerDatasource/Customization/TelekomMalaysia/Scripts/Tests/cprogs/files/ratetest';
my $write_path =
'/home/user71/RangerDatasource/Customization/TelekomMalaysia/Scripts/Tests/cprogs/files/rateop'
;
my %times ;
my $continue = 1;
$SIG{INT} = $SIG{TERM} = sub { $continue = 0 };
while ($continue) {
opendir my $dh, $file_path or die $!;
while (my $file = readdir $dh) {
my $fname = "$file_path/$file" ;
next unless -f $fname;
unless (exists $times{$file}){
my $line;
open (my $IN_FILE,"<","$file_path/$file") or die
$!." file not found" ;
while ($line=readline($IN_FILE))
{
my @cdr=split (/,/, $line) ;
$cdr[13] = $cdr[6]*5 ;
$hash{"@cdr[2,3,6,7]"}=$line;
}
close $IN_FILE ;
open (my $OUT_FILE,">","$write_path/$file.out") or
die $!;
while (my($key, $value) = each %hash)
{
print $OUT_FILE $value;
}
close $OUT_FILE;
}
}
closedir $dh ;
}
Thanks,
Mihir