why make life more difficult than strictly necessary? just run a split over the whole line, using whitespace as the divider. that way you can simply compare $event[2] to '!quit', makes things a lot easier to deal with, especially as the bot gets more complex.
drop me a line if you have more questions, i've spent more time tinkering with perl irc bots than i care to admit ;-)