Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9205619
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T23:59:29+00:00 2026-06-17T23:59:29+00:00

I am reading a file, containing integers using the 33441122 byte order. How can

  • 0

I am reading a file, containing integers using the “33441122” byte order. How can I convert the file to the “11223344” (big endian) byte order? I have tried a few things, but I am really lost.

I have read a lot about Perl, but when it comes to swapping bytes, I’m in the dark. How can I convert this:

33 44 11 22

into this:

11 22 33 44

using Perl.

Any input would be greatly appreciated 🙂

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T23:59:31+00:00Added an answer on June 17, 2026 at 11:59 pm

    You can read 4 bytes at a time, split it into individual bytes, swap them and write them out again

    #! /usr/bin/perl
    
    use strict;
    use warnings;
    
    open(my $fin, '<', $ARGV[0]) or die "Cannot open $ARGV[0]: $!";
    binmode($fin);
    open(my $fout, '>', $ARGV[1]) or die "Cannot create $ARGV[1]: $!";
    binmode($fout);
    
    my $hexin;
    my $n;
    while (($n = read($fin, $bytes_in, 4)) == 4) {
        my @c = split('', $bytes_in);
        my $bytes_out = join('', $c[2], $c[3], $c[0], $c[1]);
        print $fout $bytes_out;
    }
    
    if ($n > 0) {
        print $fout $bytes_in;
    }
    
    close($fout);
    close($fin);
    

    This will be called on the command line as

    perl script.pl infile.bin outfile.bin
    

    outfile.bin will be overwritten.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code reading a file containing unicode text (Japanese). File f
I'm reading a file using bufferedreader, so lets say i have line = br.readLine();
I am reading a file byte-by-byte. Say for example i have this byte: 0x41
I'm using Python 2.7 I'm reading a file containing iso-8859-1 coded information. After parsing,
I have a javascript file that is reading a text file containing cartesian coordinates.
I've been trying to parse a file containing lines of integers using phrase_from_file with
While reading bytes from a file containing UTF7 encoded characters the first bracket '{'
I am reading .csv file through PHP using fgetcsv(). Now I am able to
Ok, so I currently have a binary file containing an unknown number of structs
In my application I have a simple XML formatted file containing structured data. Each

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.