in reply to Problem changing only first occurence of pattern in file
I haven't much to say: I'd use Tie::File and List::Util::first.
-- David Serrano