NYIMI Jose (BMB) <[EMAIL PROTECTED]> wrote: : : I mean writing : : my @items = unpack('A2 A2', $str); : Will work for $str='abdc'; : Not for $str='abcdef'; : : Any ideas ?
use POSIX 'ceil'; my $size = 4; my @items = unpack "A$size" x ceil( (length $string) / $size ), $string; OR: use Data::Dumper; use POSIX 'ceil'; print Dumper fixed_split( 6, '12345678' ); sub fixed_split { return [ unpack "A$_[0]" x ceil( ( length $_[1] ) / $_[0] ), $_[1] ]; } HTH, Charles K. Clarkson -- Head Bottle Washer, Clarkson Energy Homes, Inc. Mobile Home Specialists 254 968-8328 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]