An example of the data in $datafile is,sub search { # Load the flatfile into a data structure. open(DB, $datafile); {local $/; $_ = <DB>} close(DB); # Start printing template print $templatehead; # Get ready for interetting datafile $recnum = 0; RECORD: while (m/\G(.*?(?<!\\)(\\\\)*)\Q$dataseperator\E/gs) { # Get the next field and unescape it. $data = $1; $data =~ m/^\n?(.*?)\n?\\?$/s; $data = $1; $data =~ s@\\\\@\\@; push @data, $1; if ($#data >= $#database) { # Get what we are searching for.... the reason we are here. $search = &getparam("search"); #gets a CGI::param() foreach $field (@data) { if(-1 != index($field,$search)) { &printfield(@data); @data = (); $recnum++; next RECORD; } } } } print $templatetail; exit(); }
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 Searching a text file by monoxide
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |