Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re^2: Problem while Data Extraction

by jpvinny28 (Initiate)
on Dec 04, 2012 at 03:30 UTC ( #1006984=note: print w/ replies, xml ) Need Help??


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


Comment on Re^2: Problem while Data Extraction
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*', $_), $/; } }

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1006984]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (13)
As of 2015-07-02 13:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (38 votes), past polls