This is even easier:
sub uppercase_username { my ($file, $username) = @_; for (@$file) { last if s/^$username:/\U$username:/; } }
It's also efficient