use warnings; # it warns about undefined values use strict; # it's a lexically scoped declaration use Data::Dumper; use Fcntl qw( SEEK_SET ); $| = 1; #flushing output my ( $mp3_size , $lines , $lines_1 , $lines_2 , $lines_3 , $lines_4 ) = "\0"; my @size = "\0"; open(FH, ,"<", "song.mp3") or die "Can not open file: $!\n"; binmode(FH); # Open in binary mode. seek( FH , 6 , SEEK_SET ) or die "Could not seek: $!"; read( FH , $lines, 4 ); # Read 32 bits (4 Bytes) and store the data in $lines Size (4 Bytes Size). ( $lines_1, $lines_2, $lines_3, $lines_4 ) = unpack ( "I I I I" , $lines ); # (I) An unsigned integer. print ("This is the content of lines_1: $lines_1\n"); print ("This is the content of lines_2: $lines_2\n"); print ("This is the content of lines_3: $lines_3\n"); print ("This is the content of lines_4: $lines_4\n"); exit(0); $mp3_size = ($size[0] & 0xFF) | (( $size[1] & 0xFF ) << 7) | (( $size[2] & 0xFF ) << 14) | (( $size[3] & 0xFF ) << 21); print Dumper($mp3_size); close (FH) or die "Can not close file: $!\n"; $| = 1; #flushing output