Re: how to read the formatted data from the file?
- From: MedranoEnrique@xxxxxxxxx
- Date: Fri, 18 Jul 2008 12:02:16 -0700 (PDT)
On Jul 14, 10:57 am, learn.tech...@xxxxxxxxx (Amit Saxena) wrote:
#! /usr/bin/perl
use warnings;
use strict;
open (PTR1, "<filename.txt") or die "Unable to open file filename.txt :
$!\n\n";
while (chomp ($str = <PTR1>))
{
sscanf($str, "%5d %11.2f", $data1, $data2);
# do whatever processing.....
}
close (PTR1);
Regards,
Amit Saxena
On Mon, Jul 14, 2008 at 8:23 PM, vikingy <viki...@xxxxxxxxx> wrote:
Hi all,
There is a file created likes this:
open File ">file.txt" or die $!;
foreach .. <..> {
printf File "%5d %11.2f\n", $data1,data2;
}
close File;
and my question is, how to read these data follow the same format as "%5d
%11.2f' from this file again?
thanks in advance!
2008-07-14
The Key Lab of Complex Systems and Intelligence Science,
Institute of Automation,
Chinese Academy of Sciences.- Hide quoted text -
- Show quoted text -
what dose $! mean
.
- Follow-Ups:
- Re: how to read the formatted data from the file?
- From: Gunnar Hjalmarsson
- Re: how to read the formatted data from the file?
- References:
- how to read the formatted data from the file?
- From: Vikingy
- Re: how to read the formatted data from the file?
- From: Amit Saxena
- how to read the formatted data from the file?
- Prev by Date: Hardware controlled by Perl
- Next by Date: Parsing XML
- Previous by thread: Re: Re: how to read the formatted data from the file?
- Next by thread: Re: how to read the formatted data from the file?
- Index(es):
Relevant Pages
|