Swapping two bytes in perl -
i trying swap 2 bytes @ time in file. thinking read in 2 bytes @ time , use reverse switch bytes around. not sure how read 2 bytes @ time in perl. can make suggestion
reading 2 bytes @ time hugely inefficient. should continue read larger blocks @ time , process bytes in buffer.
$buf =~ s/(.)(.)/$2$1/sg;
or
$buf = pack 's<*, unpack 's>*', $buf;
Comments
Post a Comment