in reply to regex issue

You have, /^$number/ but you never assign it. But more important, you match on ^-, and then change found back to 0 after printing a line, which so happens to be the first. Might i suggest..
my $found=undef; while (<FILE>){ if ($found eq $number and /^-/) { print COPYFILE "$_\n"; } elsif (/^($name)/o) { $found = $1; } } close (COPYFILE); close (FILE);

Untested, mother aproved. ;)