http://www.perlmonks.org?node_id=1006984


in reply to Re: Problem while Data Extraction
in thread Problem while Data Extraction

Input =|14 0D 2A|abc

Output =140D2A616263

The values within two pipes is hexadecimal data.. so I need to keep the values as it is in output and value outside the pipe I need to convert to ascii equivalent (abc=61,62,63) in the above example

Replies are listed 'Best First'.
Re^3: Problem while Data Extraction
by Anonymous Monk on Dec 04, 2012 at 03:45 UTC
    my @F = split(/\|/, $_, 0); foreach $_ (@F) { if (/^[\da-z]{2}(?:\s[\da-z]{2})*$/i) { s/\s+//g; print $_; } else { print unpack('H*', $_), $/; } }