A condition for a perfect-fluid space-time to be a generalized Robertson-Walker space-time