1 package FS::cust_main::Search;
4 use base qw( Exporter );
5 use vars qw( @EXPORT_OK $DEBUG $me $conf @fuzzyfields );
6 use String::Approx qw(amatch);
8 use FS::Record qw( qsearch );
10 use FS::cust_main_invoice;
13 @EXPORT_OK = qw( smart_search );
15 # 1 is mostly method/subroutine entry and options
16 # 2 traces progress of some operations
17 # 3 is even more information including possibly sensitive data
19 $me = '[FS::cust_main::Search]';
21 @fuzzyfields = ( 'first', 'last', 'company', 'address1' );
23 install_callback FS::UID sub {
25 #yes, need it for stuff below (prolly should be cached)
30 FS::cust_main::Search - Customer searching
34 use FS::cust_main::Search;
36 FS::cust_main::Search::smart_search(%options);
38 FS::cust_main::Search::email_search(%options);
40 FS::cust_main::Search->search( \%options );
42 FS::cust_main::Search->fuzzy_search( \%fuzzy_hashref );
48 =item smart_search OPTION => VALUE ...
50 Accepts the following options: I<search>, the string to search for. The string
51 will be searched for as a customer number, phone number, name or company name,
52 as an exact, or, in some cases, a substring or fuzzy match (see the source code
53 for the exact heuristics used); I<no_fuzzy_on_exact>, causes smart_search to
54 skip fuzzy matching when an exact match is found.
56 Any additional options are treated as an additional qualifier on the search
59 Returns a (possibly empty) array of FS::cust_main objects.
66 #here is the agent virtualization
68 $FS::CurrentUser::CurrentUser->agentnums_sql(table => 'cust_main');
72 my $skip_fuzzy = delete $options{'no_fuzzy_on_exact'};
73 my $search = delete $options{'search'};
74 ( my $alphanum_search = $search ) =~ s/\W//g;
76 if ( $alphanum_search =~ /^1?(\d{3})(\d{3})(\d{4})(\d*)$/ ) { #phone# search
78 #false laziness w/Record::ut_phone
79 my $phonen = "$1-$2-$3";
80 $phonen .= " x$4" if $4;
82 push @cust_main, qsearch( {
83 'table' => 'cust_main',
84 'hashref' => { %options },
85 'extra_sql' => ( scalar(keys %options) ? ' AND ' : ' WHERE ' ).
87 join(' OR ', map "$_ = '$phonen'",
88 qw( daytime night fax )
91 " AND $agentnums_sql", #agent virtualization
94 unless ( @cust_main || $phonen =~ /x\d+$/ ) { #no exact match
95 #try looking for matches with extensions unless one was specified
97 push @cust_main, qsearch( {
98 'table' => 'cust_main',
99 'hashref' => { %options },
100 'extra_sql' => ( scalar(keys %options) ? ' AND ' : ' WHERE ' ).
102 join(' OR ', map "$_ LIKE '$phonen\%'",
106 " AND $agentnums_sql", #agent virtualization
111 # custnum search (also try agent_custid), with some tweaking options if your
112 # legacy cust "numbers" have letters
116 if ( $search =~ /@/ ) {
120 'table' => 'cust_main_invoice',
121 'hashref' => { 'dest' => $search },
124 } elsif ( $search =~ /^\s*(\d+)\s*$/
125 || ( $conf->config('cust_main-agent_custid-format') eq 'ww?d+'
126 && $search =~ /^\s*(\w\w?\d+)\s*$/
128 || ( $conf->config('cust_main-custnum-display_special')
129 # it's not currently possible for special prefixes to contain
130 # digits, so just strip off any alphabetic prefix and match
131 # the rest to custnum
132 && $search =~ /^\s*[[:alpha:]]*(\d+)\s*$/
134 || ( $conf->exists('address1-search' )
135 && $search =~ /^\s*(\d+\-?\w*)\s*$/ #i.e. 1234A or 9432-D
142 if ( $num =~ /^(\d+)$/ && $num <= 2147483647 ) { #need a bigint custnum? wow
143 my $agent_custid_null = $conf->exists('cust_main-default_agent_custid')
144 ? ' AND agent_custid IS NULL ' : '';
145 push @cust_main, qsearch( {
146 'table' => 'cust_main',
147 'hashref' => { 'custnum' => $num, %options },
148 'extra_sql' => " AND $agentnums_sql $agent_custid_null",
152 # for all agents this user can see, if any of them have custnum prefixes
153 # that match the search string, include customers that match the rest
154 # of the custnum and belong to that agent
155 foreach my $agentnum ( $FS::CurrentUser::CurrentUser->agentnums ) {
156 my $p = $conf->config('cust_main-custnum-display_prefix', $agentnum);
158 if ( $p eq substr($num, 0, length($p)) ) {
159 push @cust_main, qsearch( {
160 'table' => 'cust_main',
161 'hashref' => { 'custnum' => 0 + substr($num, length($p)),
162 'agentnum' => $agentnum,
169 push @cust_main, qsearch( {
170 'table' => 'cust_main',
171 'hashref' => { 'agent_custid' => $num, %options },
172 'extra_sql' => " AND $agentnums_sql", #agent virtualization
175 if ( $conf->exists('address1-search') ) {
176 my $len = length($num);
178 # probably the Right Thing: return customers that have any associated
179 # locations matching the string, not just bill/ship location
180 push @cust_main, qsearch( {
181 'table' => 'cust_main',
182 'addl_from' => ' JOIN cust_location USING (custnum) ',
183 'hashref' => { %options, },
185 ( keys(%options) ? ' AND ' : ' WHERE ' ).
186 " LOWER(SUBSTRING(cust_location.address1 FROM 1 FOR $len)) = '$num' ".
187 " AND $agentnums_sql",
191 } elsif ( $search =~ /^\s*(\S.*\S)\s+\((.+), ([^,]+)\)\s*$/ ) {
193 my($company, $last, $first) = ( $1, $2, $3 );
195 # "Company (Last, First)"
196 #this is probably something a browser remembered,
197 #so just do an exact search (but case-insensitive, so USPS standardization
198 #doesn't throw a wrench in the works)
200 push @cust_main, qsearch( {
201 'table' => 'cust_main',
202 'hashref' => { %options },
204 ( keys(%options) ? ' AND ' : ' WHERE ' ).
206 " LOWER(first) = ". dbh->quote(lc($first)),
207 " LOWER(last) = ". dbh->quote(lc($last)),
208 " LOWER(company) = ". dbh->quote(lc($company)),
214 } elsif ( $search =~ /^\s*(\S.*\S)\s*$/ ) { # value search
215 # try (ship_){last,company}
219 # # remove "(Last, First)" in "Company (Last, First)", otherwise the
220 # # full strings the browser remembers won't work
221 # $value =~ s/\([\w \,\.\-\']*\)$//; #false laziness w/Record::ut_name
223 use Lingua::EN::NameParse;
224 my $NameParse = new Lingua::EN::NameParse(
229 my($last, $first) = ( '', '' );
230 #maybe disable this too and just rely on NameParse?
231 if ( $value =~ /^(.+),\s*([^,]+)$/ ) { # Last, First
233 ($last, $first) = ( $1, $2 );
235 #} elsif ( $value =~ /^(.+)\s+(.+)$/ ) {
236 } elsif ( ! $NameParse->parse($value) ) {
238 my %name = $NameParse->components;
239 $first = $name{'given_name_1'} || $name{'initials_1'}; #wtf NameParse, Ed?
240 $last = $name{'surname_1'};
244 if ( $first && $last ) {
246 my($q_last, $q_first) = ( dbh->quote($last), dbh->quote($first) );
249 my $sql = scalar(keys %options) ? ' AND ' : ' WHERE ';
250 $sql .= "( LOWER(cust_main.last) = $q_last AND LOWER(cust_main.first) = $q_first )";
252 push @cust_main, qsearch( {
253 'table' => 'cust_main',
254 'hashref' => \%options,
255 'extra_sql' => "$sql AND $agentnums_sql", #agent virtualization
259 # or it just be something that was typed in... (try that in a sec)
263 my $q_value = dbh->quote($value);
266 my $sql = scalar(keys %options) ? ' AND ' : ' WHERE ';
267 $sql .= " ( LOWER(last) = $q_value
268 OR LOWER(company) = $q_value
272 SELECT 1 FROM cust_location
273 WHERE LOWER(cust_location.address1) = $q_value
274 AND cust_location.custnum = cust_main.custnum
277 if $conf->exists('address1-search');
280 push @cust_main, qsearch( {
281 'table' => 'cust_main',
282 'hashref' => \%options,
283 'extra_sql' => "$sql AND $agentnums_sql", #agent virtualization
286 #no exact match, trying substring/fuzzy
287 #always do substring & fuzzy (unless they're explicity config'ed off)
288 #getting complaints searches are not returning enough
289 unless ( @cust_main && $skip_fuzzy || $conf->exists('disable-fuzzy') ) {
291 #still some false laziness w/search (was search/cust_main.cgi)
296 { 'company' => { op=>'ILIKE', value=>"%$value%" }, },
299 if ( $first && $last ) {
300 #contacts? ship_first/ship_last are gone
303 { 'first' => { op=>'ILIKE', value=>"%$first%" },
304 'last' => { op=>'ILIKE', value=>"%$last%" },
311 { 'last' => { op=>'ILIKE', value=>"%$value%" }, },
315 foreach my $hashref ( @hashrefs ) {
317 push @cust_main, qsearch( {
318 'table' => 'cust_main',
319 'hashref' => { %$hashref,
322 'extra_sql' => " AND $agentnums_sql", #agent virtualizaiton
327 if ( $conf->exists('address1-search') ) {
329 push @cust_main, qsearch( {
330 'table' => 'cust_main',
331 'addl_from' => 'JOIN cust_location USING (custnum)',
332 'extra_sql' => 'WHERE cust_location.address1 ILIKE '.
333 dbh->quote("%$value%"),
340 'hashref' => \%options,
342 'extra_sql' => " AND $agentnums_sql", #agent virtualization
345 if ( $first && $last ) {
346 push @cust_main, FS::cust_main::Search->fuzzy_search(
347 { 'last' => $last, #fuzzy hashref
348 'first' => $first }, #
352 foreach my $field ( 'last', 'company' ) {
354 FS::cust_main::Search->fuzzy_search( { $field => $value }, %fuzopts );
356 if ( $conf->exists('address1-search') ) {
358 FS::cust_main::Search->fuzzy_search( { 'address1' => $value }, %fuzopts );
365 #eliminate duplicates
367 @cust_main = grep { !$saw{$_->custnum}++ } @cust_main;
375 Accepts the following options: I<email>, the email address to search for. The
376 email address will be searched for as an email invoice destination and as an
379 #Any additional options are treated as an additional qualifier on the search
382 Returns a (possibly empty) array of FS::cust_main objects (but usually just
392 my $email = delete $options{'email'};
394 #we're only being used by RT at the moment... no agent virtualization yet
395 #my $agentnums_sql = $FS::CurrentUser::CurrentUser->agentnums_sql;
399 if ( $email =~ /([^@]+)\@([^@]+)/ ) {
401 my ( $user, $domain ) = ( $1, $2 );
403 warn "$me smart_search: searching for $user in domain $domain"
409 'table' => 'cust_main_invoice',
410 'hashref' => { 'dest' => $email },
417 map $_->cust_svc->cust_pkg,
419 'table' => 'svc_acct',
420 'hashref' => { 'username' => $user, },
422 'AND ( SELECT domain FROM svc_domain
423 WHERE svc_acct.domsvc = svc_domain.svcnum
424 ) = '. dbh->quote($domain),
430 @cust_main = grep { !$saw{$_->custnum}++ } @cust_main;
432 warn "$me smart_search: found ". scalar(@cust_main). " unique customers"
449 Returns a qsearch hash expression to search for parameters specified in
450 HASHREF. Valid parameters are
468 listref of start date, end date
472 listref of start date, end date
474 =item spouse_birthdate
476 listref of start date, end date
478 =item anniversary_date
480 listref of start date, end date
490 =item current_balance
492 listref (list returned by FS::UI::Web::parse_lt_gt($cgi, 'current_balance'))
505 my ($class, $params) = @_;
512 # initialize these to prevent warnings
519 'paydate_year' => '',
520 'invoice_terms' => '',
526 # explicit custnum(s)
529 if ( $params->{'custnum'} ) {
530 my @custnums = ref($params->{'custnum'}) ?
531 @{ $params->{'custnum'} } :
532 $params->{'custnum'};
534 'cust_main.custnum IN (' .
535 join(',', map { $_ =~ /^(\d+)$/ ? $1 : () } @custnums ) .
536 ')' if scalar(@custnums) > 0;
543 if ( $params->{'agentnum'} =~ /^(\d+)$/ and $1 ) {
545 "cust_main.agentnum = $1";
549 # do the same for user
552 if ( $params->{'usernum'} =~ /^(\d+)$/ and $1 ) {
554 "cust_main.usernum = $1";
561 #prospect ordered active inactive suspended cancelled
562 if ( grep { $params->{'status'} eq $_ } FS::cust_main->statuses() ) {
563 my $method = $params->{'status'}. '_sql';
564 #push @where, $class->$method();
565 push @where, FS::cust_main->$method();
571 if ( $params->{'address'} =~ /\S/ ) {
572 my $address = dbh->quote('%'. lc($params->{'address'}). '%');
573 push @where, "EXISTS(
574 SELECT 1 FROM cust_location
575 WHERE cust_location.custnum = cust_main.custnum
576 AND (LOWER(cust_location.address1) LIKE $address OR
577 LOWER(cust_location.address2) LIKE $address)
584 if ( $params->{'refnum'} ) {
586 my @refnum = ref( $params->{'refnum'} )
587 ? @{ $params->{'refnum'} }
588 : ( $params->{'refnum'} );
590 @refnum = grep /^(\d*)$/, @refnum;
592 push @where, '( '. join(' OR ', map "cust_main.refnum = $_", @refnum ). ' )'
598 # parse cancelled package checkbox
603 $pkgwhere .= "AND (cancel = 0 or cancel is null)"
604 unless $params->{'cancelled_pkgs'};
607 # parse without census tract checkbox
610 push @where, "(censustract = '' or censustract is null)"
611 if $params->{'no_censustract'};
614 # parse with hardcoded tax location checkbox
617 push @where, "geocode is not null"
618 if $params->{'with_geocode'};
624 foreach my $field (qw( signupdate birthdate spouse_birthdate anniversary_date )) {
626 next unless exists($params->{$field});
628 my($beginning, $ending, $hour) = @{$params->{$field}};
631 "cust_main.$field IS NOT NULL",
632 "cust_main.$field >= $beginning",
633 "cust_main.$field <= $ending";
635 if($field eq 'signupdate' && defined $hour) {
636 if ($dbh->{Driver}->{Name} =~ /Pg/i) {
637 push @where, "extract(hour from to_timestamp(cust_main.$field)) = $hour";
639 elsif( $dbh->{Driver}->{Name} =~ /mysql/i) {
640 push @where, "hour(from_unixtime(cust_main.$field)) = $hour"
643 warn "search by time of day not supported on ".$dbh->{Driver}->{Name}." databases";
647 $orderby ||= "ORDER BY cust_main.$field";
655 if ( $params->{'classnum'} ) {
657 my @classnum = ref( $params->{'classnum'} )
658 ? @{ $params->{'classnum'} }
659 : ( $params->{'classnum'} );
661 @classnum = grep /^(\d*)$/, @classnum;
664 push @where, '( '. join(' OR ', map {
665 $_ ? "cust_main.classnum = $_"
666 : "cust_main.classnum IS NULL"
679 if ( $params->{'payby'} ) {
681 my @payby = ref( $params->{'payby'} )
682 ? @{ $params->{'payby'} }
683 : ( $params->{'payby'} );
685 @payby = grep /^([A-Z]{4})$/, @payby;
687 push @where, '( '. join(' OR ', map "cust_main.payby = '$_'", @payby). ' )'
693 # paydate_year / paydate_month
696 if ( $params->{'paydate_year'} =~ /^(\d{4})$/ ) {
698 $params->{'paydate_month'} =~ /^(\d\d?)$/
699 or die "paydate_year without paydate_month?";
703 'paydate IS NOT NULL',
705 "CAST(paydate AS timestamp) < CAST('$year-$month-01' AS timestamp )"
713 if ( $params->{'invoice_terms'} =~ /^([\w ]+)$/ ) {
715 if ( $1 eq 'NULL' ) {
717 "( cust_main.invoice_terms IS NULL OR cust_main.invoice_terms = '' )";
720 "cust_main.invoice_terms IS NOT NULL",
721 "cust_main.invoice_terms = '$1'";
729 if ( $params->{'current_balance'} ) {
731 #my $balance_sql = $class->balance_sql();
732 my $balance_sql = FS::cust_main->balance_sql();
734 my @current_balance =
735 ref( $params->{'current_balance'} )
736 ? @{ $params->{'current_balance'} }
737 : ( $params->{'current_balance'} );
739 push @where, map { s/current_balance/$balance_sql/; $_ }
748 if ( $params->{'custbatch'} =~ /^([\w\/\-\:\.]+)$/ and $1 ) {
750 "cust_main.custbatch = '$1'";
753 if ( $params->{'tagnum'} ) {
754 my @tagnums = ref( $params->{'tagnum'} ) ? @{ $params->{'tagnum'} } : ( $params->{'tagnum'} );
756 @tagnums = grep /^(\d+)$/, @tagnums;
759 my $tags_where = "0 < (select count(1) from cust_tag where "
760 . " cust_tag.custnum = cust_main.custnum and tagnum in ("
761 . join(',', @tagnums) . "))";
763 push @where, $tags_where;
769 # setup queries, subs, etc. for the search
772 $orderby ||= 'ORDER BY custnum';
774 # here is the agent virtualization
776 $FS::CurrentUser::CurrentUser->agentnums_sql(table => 'cust_main');
778 my $extra_sql = scalar(@where) ? ' WHERE '. join(' AND ', @where) : '';
782 my $count_query = "SELECT COUNT(*) FROM cust_main $extra_sql";
786 FS::UI::Web::cust_sql_fields($params->{'cust_fields'}),
789 my(@extra_headers) = ();
790 my(@extra_fields) = ();
792 if ($params->{'flattened_pkgs'}) {
795 $addl_from .= ' LEFT JOIN cust_pkg USING ( custnum ) ';
797 if ($dbh->{Driver}->{Name} eq 'Pg') {
802 SELECT pkg FROM cust_pkg LEFT JOIN part_pkg USING ( pkgpart )
803 WHERE cust_main.custnum = cust_pkg.custnum $pkgwhere
808 } elsif ($dbh->{Driver}->{Name} =~ /^mysql/i) {
809 push @select, "GROUP_CONCAT(part_pkg.pkg SEPARATOR '|') as magic";
810 $addl_from .= ' LEFT JOIN part_pkg USING ( pkgpart ) ';
811 #$pkg_join .= ' LEFT JOIN part_pkg USING ( pkgpart ) ';
813 warn "warning: unknown database type ". $dbh->{Driver}->{Name}.
814 "omitting package information from report.";
818 SELECT COUNT(cust_pkg.custnum = cust_main.custnum) AS count
819 FROM cust_main $addl_from $extra_sql $pkgwhere
820 GROUP BY cust_main.custnum ORDER BY count DESC LIMIT 1
823 my $sth = dbh->prepare($header_query) or die dbh->errstr;
824 $sth->execute() or die $sth->errstr;
825 my $headerrow = $sth->fetchrow_arrayref;
826 my $headercount = $headerrow ? $headerrow->[0] : 0;
827 while($headercount) {
828 unshift @extra_headers, "Package ". $headercount;
829 unshift @extra_fields, eval q!sub {my $c = shift;
830 my @a = split '\|', $c->magic;
831 my $p = $a[!.--$headercount. q!];
838 if ( $params->{'with_geocode'} ) {
840 unshift @extra_headers, 'Tax location override', 'Calculated tax location';
841 unshift @extra_fields, sub { my $c = shift; $c->get('geocode'); },
843 $c->set('geocode', '');
844 $c->geocode('cch'); #XXX only cch right now
846 push @select, 'geocode';
847 push @select, 'zip' unless grep { $_ eq 'zip' } @select;
848 push @select, 'ship_zip' unless grep { $_ eq 'ship_zip' } @select;
851 my $select = join(', ', @select);
854 'table' => 'cust_main',
856 'addl_from' => $addl_from,
858 'extra_sql' => $extra_sql,
859 'order_by' => $orderby,
860 'count_query' => $count_query,
861 'extra_headers' => \@extra_headers,
862 'extra_fields' => \@extra_fields,
867 =item fuzzy_search FUZZY_HASHREF [ OPTS ]
869 Performs a fuzzy (approximate) search and returns the matching FS::cust_main
870 records. Currently, I<first>, I<last>, I<company> and/or I<address1> may be
873 Additional options are the same as FS::Record::qsearch
878 my( $self, $fuzzy ) = @_;
879 # sensible defaults, then merge in any passed options
881 'table' => 'cust_main',
890 check_and_rebuild_fuzzyfiles();
891 foreach my $field ( keys %$fuzzy ) {
893 my $all = $self->all_X($field);
894 next unless scalar(@$all);
897 $match{$_}=1 foreach ( amatch( $fuzzy->{$field}, ['i'], @$all ) );
900 foreach ( keys %match ) {
901 if ( $field eq 'address1' ) {
902 #because it lives outside the table
903 my $addl_from = $fuzopts{addl_from} .
904 'JOIN cust_location USING (custnum)';
905 my $extra_sql = $fuzopts{extra_sql} .
906 " AND cust_location.address1 = ".dbh->quote($_);
907 push @fcust, qsearch({
909 'addl_from' => $addl_from,
910 'extra_sql' => $extra_sql,
913 my $hash = $fuzopts{hashref};
914 $hash->{$field} = $_;
915 push @fcust, qsearch({
922 push @cust_main, grep { ! $fsaw{$_->custnum}++ } @fcust;
925 # we want the components of $fuzzy ANDed, not ORed, but still don't want dupes
927 @cust_main = grep { ++$saw{$_->custnum} == scalar(keys %$fuzzy) } @cust_main;
935 =head1 UTILITY SUBROUTINES
939 =item check_and_rebuild_fuzzyfiles
943 sub check_and_rebuild_fuzzyfiles {
944 my $dir = $FS::UID::conf_dir. "/cache.". $FS::UID::datasrc;
945 rebuild_fuzzyfiles() if grep { ! -e "$dir/cust_main.$_" } @fuzzyfields;
948 =item rebuild_fuzzyfiles
952 sub rebuild_fuzzyfiles {
954 use Fcntl qw(:flock);
956 my $dir = $FS::UID::conf_dir. "/cache.". $FS::UID::datasrc;
957 mkdir $dir, 0700 unless -d $dir;
959 foreach my $fuzzy ( @fuzzyfields ) {
961 open(LOCK,">>$dir/cust_main.$fuzzy")
962 or die "can't open $dir/cust_main.$fuzzy: $!";
964 or die "can't lock $dir/cust_main.$fuzzy: $!";
966 open (CACHE, '>:encoding(UTF-8)', "$dir/cust_main.$fuzzy.tmp")
967 or die "can't open $dir/cust_main.$fuzzy.tmp: $!";
969 foreach my $field ( $fuzzy, "ship_$fuzzy" ) {
970 my $sth = dbh->prepare("SELECT $field FROM cust_main".
971 " WHERE $field != '' AND $field IS NOT NULL");
972 $sth->execute or die $sth->errstr;
974 while ( my $row = $sth->fetchrow_arrayref ) {
975 print CACHE $row->[0]. "\n";
980 close CACHE or die "can't close $dir/cust_main.$fuzzy.tmp: $!";
982 rename "$dir/cust_main.$fuzzy.tmp", "$dir/cust_main.$fuzzy";
988 =item append_fuzzyfiles FIRSTNAME LASTNAME COMPANY ADDRESS1
992 sub append_fuzzyfiles {
993 #my( $first, $last, $company ) = @_;
995 check_and_rebuild_fuzzyfiles();
997 use Fcntl qw(:flock);
999 my $dir = $FS::UID::conf_dir. "/cache.". $FS::UID::datasrc;
1001 foreach my $field (@fuzzyfields) {
1006 open(CACHE, '>>:encoding(UTF-8)', "$dir/cust_main.$field" )
1007 or die "can't open $dir/cust_main.$field: $!";
1008 flock(CACHE,LOCK_EX)
1009 or die "can't lock $dir/cust_main.$field: $!";
1011 print CACHE "$value\n";
1013 flock(CACHE,LOCK_UN)
1014 or die "can't unlock $dir/cust_main.$field: $!";
1028 my( $self, $field ) = @_;
1029 my $dir = $FS::UID::conf_dir. "/cache.". $FS::UID::datasrc;
1030 open(CACHE, '<:encoding(UTF-8)', "$dir/cust_main.$field")
1031 or die "can't open $dir/cust_main.$field: $!";
1032 my @array = map { chomp; $_; } <CACHE>;
1043 L<FS::cust_main>, L<FS::Record>