On 6/22/05, Angerstein <[EMAIL PROTECTED]> wrote: > I have a problem reading strings out of a binaery file. > > The last 128 Byte of the File contains a String I want to work with. > > (sorry, this code is windows, feel free to flame me ^^) > ################################ > my $tsize = 128; > my $fsize = (-s "d:\\mp3\\forseti.mp3"); > my $offset = ($fsize - $tsize); > open(INF, "d:\\mp3\\forseti.mp3"); > seek(INF, $offset, 0); > $tag = <INF>; > @id3v1 = split (//, $tag); > $id3v_t = unpack("B8","$id3v1[125]"); > print $id3v_t; > ################################ > I get: > >00000000 > > If I print the whole string it looks like: > This is what I get 2002 > ^^^^^^ ^^^^^^^^^^^ ^^^^^^^^ ^^^^^^^^^^^^^ > > The Parts I markt are no whitespaces. They are binaery 00000000. > > Is there something I could do to transform or remove this null-chars?
CPAN has modules for working with ID3 tags[1]. That said, you can replace nulls with a space with: $id3v_t =~ s/\0+/ /g; [1] <http://search.cpan.org/search?query=id3&mode=all> -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>