On Wed, Apr 27, 2011 at 2:48 PM, Shawn H Corey <shawnhco...@ncf.ca> wrote:
> On 11-04-27 12:47 PM, Jim Gibson wrote: > >> The metasymbol \d matches the characters [0-9], not the extended >> hexadecimal >> set that includes A-Z. To match those, construct your own character class: >> >> [0-9A-Z] >> > > You can use the POSIX xdigit character class instead: Or the Unicode character propriety[0] \p{Hex} (or \p{Hex_Digit} or whichever form you prefer the most). Or, since the data seems to always come in the same form, instead of using a regex, you could pull out unpack [1]: use 5.010; while (<DATA>) { say join ',', (unpack "A5 A24 A*")[0,-1]; } You can learn more about pack/unpack in perlpacktut[2] Or you could use substr[3]: while (<DATA>) { chomp; say join ',', substr($_, 0, 4), substr($_, 29); } Brian. [0] http://perldoc.perl.org/perluniprops.html [1] http://perldoc.perl.org/functions/unpack.html [2] http://perldoc.perl.org/perlpacktut.html [3] http://perldoc.perl.org/functions/substr.html