in reply to Search a string through IO::File API, and then print the lines after match in the file.
Do you expect IO::File to provide some sort of magic pixies that just know a priori where your search term is in the file? Unless you have some sort of external index the only way to read through a file and find a matching line is to, well, read through the file looking for the matching line.
Now if this is something you need to do repeatedly then you do want to look into building an index (there's an example in the Perl Cookbook, and I'm sure someone can chime in with supersearch fodder to turn up examples here; tell, seek, and some form of persistent hash are the key ingredients), or depending on the exact nature of your real problem maybe look at some sort of RDBMS capable of keeping an index for you.
The cake is a lie.
The cake is a lie.
The cake is a lie.
|
|---|