Hi Jon and Jose, Jose Alves de Castro wrote on 27.05.2004:
>On Thu, 2004-05-27 at 10:10, Jon Herbry wrote: >>Hi, anybody have idea find the number in a file? Assume I create a >>file call >"sample" >>and have content below: ------------------------------------ Hi, >>Jame where are you? How old are you? when you free? can you coming >>my home? ----------------------------------------- assume if i want >>know string word "old" locate in which line and return the >entire sentences, so how i tell perl to find the string for example >above? Please help. > >If you're using a Unix system, try the command "grep". I do believe >MS-DOS like systems include a "find" utility with the same purpose. > The original poster asked for the line number. The variable $. will do what he wants, it contains the number of the line just read from an open filehandle: $INPUT_LINE_NUMBER $NR $. [ALL] The current record number (usually line number) for the last filehandle you read from (or called seek or tell on). The value may be different from the actual physical line number in the file, depending on what notion of "line" is in effect--see $/ ($INPUT_RECORD_SEPARATOR) on how to affect that. An explicit close on a filehandle resets the line number. Because <> never does an explicit close, line numbers increase across ARGV files (but see examples under eof). Localizing $. also localizes Perl's notion of "the last read filehandle". (Mnemonic: many programs use "." to mean the current line number.) HTH, Jan -- There's no place like ~/ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>