I haven't really used map very often, so this is really more for my own education. Here's the code I'm using:
# I'm using URI::Find, so @_ is defined automagically
@_ = ('https://www.example.com/?fbclid=whatever#utm_campaign=foo&utm_source=bar',
'https://www.example.com/?fbclid=whatever#utm_campaign=foo&utm_source=bar');
# remove utm_whatever, ocid, trkid, gclid, fbclid, data-whatever, role, cite, itxt, and itxt-whatever
map s#(\?|&(amp;)?)(utm_\w+?|ocid|trkid|gclid|fbclid|data-[\w-]+?|role|cite|itxt[\w-]*?)=[^&]+#$1#gi, @_;
# remove repeating &
map s#(&(amp;)?&(amp;)?)+#&#, @_;
# remove trailing ? or &
map s#(\?|&(amp;)?)+$##, @_;
These obviously have to be done in order; remove the offending params, which might leave repeating &... then remove the repeating &, which might leave a trailing ? or &... then remove the trailing ? or &.
Is there a way to do all of this with one map, though, instead of using 3 different ones?