#!/usr/bin/perl while (<>) { if (/author=/) { my $i; s/,/($i^=1) ? "," : " and"/ge; } print; }