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

Popular posts from this blog

how to proxy from https to http with lighttpd -

android - Automated my builds -

python - Flask migration error -