You use the find data in a different way, of course, but the theory applies just the same. No point going through all the trouble of converting your fields if the string you're looking for isn't in the current line, and you shouldn't read the file all in at once unless you know it's always going to be small (and in that case, a simple open-read-close is most efficient).use strict; my $str = 'MySql'; while (<DATA>) { next if index ($_, $str) == -1; split(/\|/); for (0..6) { print "String \"$str\" found in field $_ of line " . ($.-1) . +"\n" if index($_[$_], $str) != -1; } } __DATA__ Test|Subject|test@subject.com|Male|Perl-Database|good|on| My|Tester|my@tester.com|Female|Perl-Database|very good|on| Blank|Worker|blank@worker.com|Male|MySql-Database|the best!|off| Someone|Somewhere|someone@somewhere.com|Female|Mysql-Database|great|of +f| Adding|Test|add@test.com|Male|Perl-Database|Great product!|on|
In reply to Re: Searching a text file
by TedPride
in thread Searching a text file
by monoxide
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |