[Chicago-talk] Regular expression

Andrew Rodland arodland at comcast.net
Wed Feb 6 20:04:38 PST 2008

On Wednesday 06 February 2008 01:19:42 pm Andy Lester wrote:
> my @dashes = split( /\s+/, $dashes );  # Make an array of each line of
> dashes
> my @widths = map { length } @dashes;   # And get the length of each one
> my $mask_for_unpack = sprintf( 'A%d A1 A%d A1 A%d', @widths );

I've used this very trick in the past, and it works beautifully. You can 
actually use 'x1' in place of 'A1' in the unpack template to throw away the 
space between columns instead of returning them.


More information about the Chicago-talk mailing list