-1

I have a file with hex codes. Example:

my $O1ol1ooI = "";
my $lOI100 = "";
my $oO10OI0 = 99;
my @olIIO1 = `df -h`;

chomp(my $I0110 = `hostname`);

foreach (@olIIO1) {
    if (m/(\d+)% (.*)/ && $1 > $oO10OI0) {
        $lOI100 = "\x66\x75\x6C\x6C";
    }
}


my $O1ol1ooI = "";
my $lOI100 = "";
my $oO10OI0 = 99;
my @olIIO1 = `df -ih`;

chomp(my $I0110 = `hostname`);

foreach (@olIIO1) {
    if (m/(\d+)% (.*)/ && $1 > $oO10OI0) {
        $lOI100 = "\x66\x75\x6C\x6C";
    }
}

if ($ol0IOoO eq "\x2D\x2D\x64\x65\x62\x75\x67\x3D\x6F\x6E") {
$OloOlOlII->show_progress;
}

What i need is a regex to be able to extract the hex codes from this file like \x66\x75\x6C\x6C, \x66\x75\x6C\x6C and etc.

Note: The file is so much longer.

Thanks in advance

Navid Zarepak
  • 4,148
  • 1
  • 12
  • 26
  • `\\x[[:alnum:]]{2,6}` – ctwheels Oct 05 '17 at 13:12
  • Your code isn't creating strings containing things like "\x41" - they're converted into the character represented by those hex numbers (ie "A" in this example). – Chris Turner Oct 05 '17 at 13:55
  • also you should use more meaningful names for your variables and definitely add "use strict;" at the least to the beginning to pick up where you've misspelt any – Chris Turner Oct 05 '17 at 13:58
  • @ChrisTurner Its a system which we are trying to make it hard to read. (to avoid some problems from other trying to null the system or ... ) – Navid Zarepak Oct 05 '17 at 14:08
  • 2
    Making your source code hard to read as a design goal is abhorrently misguided. – DavidO Oct 05 '17 at 14:28
  • @DavidO This is a license file which user can access it by some digging in their Linux machine. and using this file they can speed up the the process of cracking the software. this file will be used by a software and no one need to be able to read it. and if we need any changes, we have the normal file to make that changes and then we will compile it back to this form. we're talking about machines reading a file like this not humans. Hope you understand what the ACTUAL point is. – Navid Zarepak Oct 05 '17 at 17:38

1 Answers1

2

A regular expression to match a hex code like that is straightforward:

\\x[0-9a-f][0-9a-f]

or

\\x[[:xdigit:]]{2}

Is that enough to solve your problem?

neuhaus
  • 3,886
  • 1
  • 10
  • 27