For Programmers: Free Programming Magazines  


Home > Archive > PERL Modules > July 2004 > Pattern Search and Extraction of Floating Point number to csv file









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Pattern Search and Extraction of Floating Point number to csv file
Ram Laxman

2004-07-15, 3:56 pm

Hi all,
Iam new to perl programming. I have written a program which
read a text file and import some values to the csv file searching some
tags(keyword) in the text file.

Below is the format of text file:

No of transactions = 10
Data exchanged with device = 0.5 bytes
Data sent to device = 0.04 KBytes

while( $key = <TEXTFILE> ) {
# check if it matches the tag
if ( $key =~ /$tag/i ) {
@arr_field = split( /$tag/i, $key );
foreach $afield( @arr_field ) {

if( $afield =~ /(\d+)/ ) {
$field = $1; # extract the numerical field
}

}
print CSV "$field\,"; # writes the numerical field to the
result file
last;

The statement below extracts the numerical field.
if( $afield =~ /(\d+)/

I don't know how to extract the floating point numbers.(For example
Data exchanged with device = 0.5 bytes) without truncation and
want to save the same value in my csv file.

Could anybody help me in this regard?

Regards
Ram Laxman
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com