Re: Perl - Joining of Binary values



On 11/17/06, Dr.Ruud <rvtol+news@xxxxxxxxxxxx> wrote:

"Dr.Ruud" schreef:

> my $data = join("\n", map {sprintf "%08b", $_}
> map hex, <DATA> =~ /[[:xdigit:]]+/g) . "\n" ;
>
> 1 while $data =~ s/(.+?)(.{7}\n.*)/$2$1/ ;

Better:

my $data = join "\n", map {sprintf "%08b", $_}
map hex, <DATA> =~ /[[:xdigit:]]+/g ;

$data =~ s/(?<=.)\z/\n/
while $data =~ s/(.+?)(.{7}\n.*)/$2$1/ ;


Alternative for that last (folded) line:

for ($data) {s/(?<=.)\z/\n/ while s/(.+?)(.{7}\n.*)/$2$1/}

--
Affijn, Ruud

"Gewoon is een tijger."

--
To unsubscribe, e-mail: beginners-unsubscribe@xxxxxxxx
For additional commands, e-mail: beginners-help@xxxxxxxx
<http://learn.perl.org/> <http://learn.perl.org/first-response>

Thanks Dr.Ruud. Since i am unable to understand the working of the code
which you have written, I request you to explain the working for me.



Thanks and Regards,
Dharshana


Relevant Pages

  • RE: perl if/then
    ... "Gewoon is een tijger." ... To unsubscribe, e-mail: beginners-unsubscribe@xxxxxxxx ... For additional commands, e-mail: beginners-help@xxxxxxxx ...
    (perl.beginners)
  • Re: need help parsing file for output
    ... "Gewoon is een tijger." ... To unsubscribe, e-mail: beginners-unsubscribe@xxxxxxxx ... For additional commands, e-mail: beginners-help@xxxxxxxx ...
    (perl.beginners)
  • Re: Bug in Perl
    ... or to be nearer to what he/she wanted to do just: ... "Gewoon is een tijger." ... To unsubscribe, e-mail: beginners-unsubscribe@xxxxxxxx ... For additional commands, e-mail: beginners-help@xxxxxxxx ...
    (perl.beginners)
  • Re: IDE for Perl in Linux
    ... GNU Emacs my friend. ... "Gewoon is een tijger." ... To unsubscribe, e-mail: beginners-unsubscribe@xxxxxxxx ...
    (perl.beginners)
  • Re: [opensuse] Why are there not more using Linux?
    ... With thanks to all who've made this what it is, and with continuing faith that one day it'll be what it deserves to be, and have the acceptance and mainstream support it deserves. ... I recently bought a VIC 20, which was my first computer. ... To unsubscribe, e-mail: opensuse+unsubscribe@xxxxxxxxxxxx ... For additional commands, e-mail: opensuse+help@xxxxxxxxxxxx ...
    (SuSE)