473,385 Members | 1,474 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Hexadecimal Operation in Perl

I have this operation:

$MID = ($MID ^ (($enc_val1 >> 8 >> 8) & 0x7FFF)) & 0xFFFF;


But I don't know what the ">>" and "^" stand for. Could someone clarify it for me?

$MID = 0x0072
$enc_val1 = 0x169973C5
Sep 6 '12 #1
2 2850
Rabbit
12,516 Expert Mod 8TB
They are bitwise operators. The ^ is an exclusive or operator and the >> is a shift right operator.
Sep 6 '12 #2
RonB
589 Expert Mod 512MB
Why are you using so much hex? It only serves to obfuscate the statement for no real apparent reason.

Replacing the unnecessary hex with their integer values, that statement cleans up to this:
Expand|Select|Wrap|Line Numbers
  1. $MID = (114 ^ ((379155397 >> 16) & 32767)) & 65535;

>> is the "bit shift right" operator and ^ is the "exclusive-or" operator.
The Bitwise Operators
Sep 6 '12 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Chris Pruett | last post by:
An odd (to me) behavior I was hoping someone could explain. Take the simple command: perl -e 'print 0xCEC5 + 0xFFFFE253 & 0xFFFF' I tried this on a number of computers. Most give 0xFFFF, ...
0
by: Tom McCarthy | last post by:
I received a file that contains a field that consists of two 32 bit hexadecimal numbers. The field is supposed to represent a date / time value. It originated from a Windows system. Is their a...
0
by: Jean-Marie Gouarné | last post by:
The new OpenOffice::OODoc distribution, V 1.203, is available from CPAN today. It's an Expat-based Perl extension allowing direct read/write access to OpenOffice.org (XML) documents. It provides...
5
by: Damon | last post by:
I'm getting '', hexadecimal value 0x02, is an invalid character when I'm deseralizing XML from a 3rd party XML gateway. How do I get rid of these hexadecimal values before I deserialize? Cheers...
0
by: josh | last post by:
Hey All, Thanks Dino for your previous help. I have a working Perl script on a Linux box using a soap::lite wrapper. I am trying to use the Perl module WSDL::generator to generate a WSDL. ...
0
by: Peter Conrey | last post by:
I have a perl web service (using SOAP::Lite) with a method called "Detail" that returns a strucure (hash reference to be exact). It works fine when consumed by a Perl client, but when I try to...
0
by: ryan | last post by:
I've been tasked with consuming a Perl web service that was written by a person in a different department of my company. The problem is it's the guy's first attempt at web services and he doesn't...
0
by: Onecarb | last post by:
Hi, i need help for a (maybe) simple function :). I need to send by serial port a series of hexadecimal bytes with a xor control character. The language i use could not work with hexadecimal and...
6
by: Andrea | last post by:
Hi, suppose that I have a string that is an hexadecimal number, in order to print this string I have to do: void print_hex(unsigned char *bs, unsigned int n){ int i; for (i=0;i<n;i++){...
2
by: jason m | last post by:
I am wondering how to translate this perl code to php. It seems the md5 function is the same when using hexadecimal in perl but I'm not sure what this md5->add code does. Perl: my...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.