#!/usr/local/bin/perl -w use strict; $|++; use FileHandle; my $path = "/path/to"; my $database = "database"; my $DATABASE = new FileHandle; ## what are these? what are they initialized to? my ($m, $p, $r, $s, $p); open ($DATABASE,"< ", $path/$database") or die("ERROR: cannot open database $path/$database! $!"); while() { my $rec = $_; chomp($rec); ## not good variable names, be descriptive my ($a, $b, $c, $d, $e, $f) = split(/\|/, $rec); if ($s =~ /$d/g) { if ($r =~ /$e/g){ if ($m =~ /$fa/g){ print "$b\n"; if ($c eq "Y"){ print "$a - tal\n"; } if ($p eq "Y"){ print "$e"; } } } ## ... do more stuff } ## ... do more stuff } close($DATABASE) or die("ERROR: cannot close database $path/$database! $!");