in reply to Regex confusion
I agree with both fglock and Enlil. Using split is the way to go. Of the two solutions they provided, Enlil's is probably better because it makes the least assumptions about the data.
Even better than splitting on /\s+/ is splitting on a single literal space. This is a special case for split and eliminates the leading null field in the event that your input has leading space. This is almost always what people really want when they need to split on whitespace.
Also, I'd just assign a slice of split's return list to my variables to eliminate the use of an unnecessary named temporary array.
my ($procType, $procName, $traceLevel) = (split ' ', $p->{cmd})[0,2,6] +;
-sauoq "My two cents aren't worth a dime.";
|
|---|