in reply to regex issue

Parentheses have a special meaning in regular expressions (capturing). You have to escape them to get the literal characters. Also, there are too many double quotes in your expression:
$command =~m/\s*"sort\s+by\s+\((CPU|USER|PID|MEM|COMMAND)\)"/i

Replies are listed 'Best First'.
Re^2: regex issue
by perlNewby (Initiate) on Feb 17, 2012 at 08:44 UTC

    I was excited when I saw your post, but it still doesn't work correctly. It now only matches: sort by user, sort by pid, and sort by mem, but will not match sort by cpu or sort by command. Any other suggestions?

      OK, I probably do not undestand what you are trying to match. Can you show several strings that should be matched and several that should not?

        moritz got it for me thanks though. In case you still are wondering, I wanted "sort by mem", " sort by MEM", "sort by CPU ", etc. to work(no quotations obviously, was just putting them there to show that spaces are not supposed to matter). I wanted it case insensitve, space insensitive which it was, apparently the "" around sort was messing it up. I put them in because sort turned red like it was using it as the sort function which I obviously did not want so I was trying to force it to see it as a string. Apparently it does not matter because as moritz showed me, it works fine. Thanks agian