Piecewise linear models are attractive when modeling a wide range of nonlinear phenomena but determining simultaneously the domain decomposition and the corresponding parameter values is a challenging problem. We show that this problem can be formulated as that of partitioning an inconsistent linear system into a minimum number of consistent subsystems and we describe a greedy algorithm, based on a simple variant of the perceptron procedure, which provides good approximate solutions in a short amount of time. The general approach is applied to piecewise linear modeling of time series.