I want to do something like this, but I also want to remove the found element from @files. my @nfiles=grep /^car/, @files; can anyone point me in the right direction, I am thinking map is needed but I don't have much confidence using it.