http://www.perlmonks.org?node_id=1007779


in reply to Re^2: Regular expression assistance
in thread Regular expression assistance

Okay, much better. Assuming you want to do this in the midst of a script and not just piping one liners about, I would use more operations rather than be super sparse on characters. First, since you have a string that is internally-delimited by newlines, you can use . to match any character that is not a new line. This means you can actually grab your line using $cdp =~  m/(.*0x01.*)/, storing the line in $1. You could then split that on whitespace and grab the 8th field with (split /\s+/, $1)[7]. So collecting all your 8th field matches:
my @switch; while ($cdp =~ m/(.*0x01.*)/g) { push @switch, (split /\s+/, $1)[7]; }
If this is not your intent and the way forward is unclear, post explicit desired output so the goal is clear.

#11929 First ask yourself `How would I do this without a computer?' Then have the computer do it the same way.