"Dr.Ruud" schreef: Some explanation of the tight code follows.
> my $data = join "\n", map {sprintf "%08b", $_} > map hex, <DATA> =~ /[[:xdigit:]]+/g ; Let's start at the end: @r1 = <DATA> =~ /[[:xdigit:]]+/g ; That creates a list of the sequences of hexadecimal digit characters out of the line read from <DATA>. So it results in "qw(31 59 4C 15 53 DD 54 31)", which is a list of strings. Maybe "<DATA> =~ /([[:xdigit:]]+)/g" (with brackets) is more efficient (like when $& and $1 are involved). The following step: @r2 = map hex, @r1 ; transforms this list to "(0x31, 0x59, ... , 0x54, 0x31)", which is a list of integers. The next step: @r3 = map {sprintf "%08b", $_} @r2 ; transforms this list to "qw(00110001 01011001 ... 01010100 00110001)", which is a list of strings. The next step: my $data = join "\n", @r3 ; creates a single string from the list, with "\n" as glue. So $data is "00110001\n01011001\n...\n01010100\n00110001". > $data =~ s/(?<=.)\z/\n/ > while $data =~ s/(.+?)(.{7}\n.*)/$2$1/ ; This appends a \n to $data if there is a non-\n character at the end of $data, and shortens each embedded line to the trailing 7 characters, moving the surplus from the current line to the end of the next line (and that all as many times as possible). To see what goes on, make it: do{ $data =~ s/(?<=.)\z/\n/; print "$data\n\n" } while $data =~ s/(.+?)(.{7}\n.*)/$2$1/ ; -- Affijn, Ruud "Gewoon is een tijger." -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>