In fact, sscanf belongs to the String::Scanf, when I install this module,program works ok.
thank you all the same! 2008/7/14 Amit Saxena <[EMAIL PROTECTED]>: > You need not to call any specific module for sscanf. > > Could you tell me the line number where perl complains ? > > Also please post your complete code ! > > Regards, > Amit Saxena > > 2008/7/14 vikingy <[EMAIL PROTECTED]>: > > thank you for your help! >> when I do it as you suggested,I get the error message "undefined >> subroutine @main:: sscanf called at ..." >> would you tell me which module does the function"sscanf" belong to ? >> "String" ??? >> >> >> 2008-07-14 >> ------------------------------ >> The Key Lab of Complex Systems and Intelligence Science, >> Institute of Automation, >> Chinese Academy of Sciences. >> ------------------------------ >> *发件人:* Amit Saxena >> *发送时间:* 2008-07-14 22:57:03 >> *收件人:* vikingy >> *抄送:* beginners >> *主题:* Re: how to read the formatted data from the file? >> #! /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 <[EMAIL PROTECTED]> 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. >>> >> >> >