1.

Solve : Need some help for perl script?

Answer»

Hi,

Anyone can help me to write a perl script..?  I have text FILE which contains thousands of lines as below:

00088A10160182000019         401208160182009093     090720084413008C090720084425008C0100032 8693548003400900001010160182000019         010160182000019         010160182009093         0401208160182009093     00000000000100502181070008037     60181000117             60181000010             502181070002635     


00088A1020000                      401208160182009093     090720084658008C090720084700008C0100032 8693989005000900001010160182003883         010160182003883         010160182009093         0401208160182009093     00000000000100502181070008037     60181000117             60181000010             502181070002871     

#!/usr/local/bin/perl

$data_file="info.txt";
OPEN(INFO, $data_file) || die("COULD not open file");
raw_data=<INFO>;

close(INFO);

$filename="info1.txt";
open( FILE, "> $filename" ) || die("Could not open file!");

foreach $line (raw_data){
if(substr($line,8,5)=/20000/){
PRINT FILE "$line";
$new="$line";
$new=$newline.$line;
}#end if
}#end foreach

close(FILE);
My input should be the whole line containing "20000" at column 8 which the second line as below.

00088A1020000                      401208160182009093     090720084658008C090720084700008C0100032 8693989005000900001010160182003883         010160182003883         010160182009093         0401208160182009093     00000000000100502181070008037     60181000117             60181000010             502181070002871     

My script above is'nt working . Please help. THKS.



Discussion

No Comment Found