use strict; use Tie::File; # skipping all sorts of fun to get to this: tie @array, 'Tie::File', "$mf_dir$filename", recsep => '}', autochomp => 0; $array[$user_section] =~ s/username =\> $username/username =\> $newusername/; # or something like that