Re: how to read the formatted data from the file?

On Jul 14, 10:57 am, (Amit Saxena) wrote:
#! /usr/bin/perl

use warnings;
use strict;

open (PTR1, "<filename.txt") or die "Unable to open file filename.txt :

while (chomp ($str = <PTR1>))
      sscanf($str, "%5d %11.2f", $data1, $data2);

      # do whatever processing.....


close (PTR1);

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!


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


Relevant Pages