in reply to unexpected loop behaviour when pattern matching

You're treating arbitrary text as a regex pattern, so it doesn't match what you expect it to match and it you get regex pattern compilation errors:
Unmatched ( in regex; marked by <-- HERE in m/mozilla/5.0 ( <-- HERE m +acintosh; u; safari/525/ at script.pl line 30.

I'm rather curious as to why you didn't mention that you were getting an error.

Perhaps you want

# Does $user contain the string from $useragent $user =~ /\Q$useragent\E/
or
# Is $user equal to the string from $useragent $user =~ /^\Q$useragent\E\z/
or
# Is $user equal to the string from $useragent $user eq $useragent

Replies are listed 'Best First'.
Re^2: unexpected loop behaviour when pattern matching
by jonnyfolk (Vicar) on Dec 14, 2009 at 16:13 UTC
    Thanks for the advice - my apologies for not pointing out the error message. I wasn't able to access my error logs but should have switched on Carp so my bad!!