in reply to Simple regex

this is the code which i use finally. it works. thanks you guys :)
$return{"objdump"} = join( "", $return{"objdump"} =~ /[0-9a-f]{8}/g ); my $length = length $return{"objdump"}; for( my $i = 0 ; $i < $length ; $i += 2 ) { print "\\x" . substr( $return{"objdump"}, $i, 2 ); }

Replies are listed 'Best First'.
Re^2: Simple regex
by Roy Johnson (Monsignor) on Jan 19, 2005 at 20:18 UTC
    Here's another way to do the same thing:
    $return{"objdump"} =~ s/.*?([0-9a-f]{8}|$)/$1/gs; print "\\x$_" for $return{"objdump"} =~ /../g;
    The first line strips out every string preceding an eight-digit hex number or end of string. The second line splits the string into two-digit substrings and prints them.

    Caution: Contents may have been coded under pressure.