Hello,
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?
(Something small and smart.)
I thought about
$x=0;
foreach @id3v1 ($char){
$testit = unpack("B8", $char);
if ($testit =~ m/0{8}/) {
$id3v1[$x] = "";
}
$x++;
}
but it this is not very smart or small...
Thanks,
Bastian
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>