Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: Problem while Data Extraction

by GrandFather (Sage)
on Dec 04, 2012 at 03:42 UTC ( #1006985=note: print w/ replies, xml ) Need Help??


in reply to Problem while Data Extraction

It may be that on my first reading of your node I understood it backwards, in which case the following code is more likely useful:

#!/usr/bin/perl use strict; use warnings; while (<DATA>) { chomp; my @parts = split /(\|[^\|]*\|)/; for my $part (@parts) { if ($part =~ /\|(.*)\|/) { $part = join '', $part =~ /([\da-f]+)/ig; } else { $part = join '', map {sprintf '%02x', ord $_} split '', $p +art; } print $part; } print "\n"; } __DATA__ |30 31 32 33 34|.dropbox.com User-Agent|3A|Google|20 20|Desktop

Prints:

30313233342e64726f70626f782e636f6d 557365722d4167656e743A476f6f676c6520204465736b746f70
True laziness is hard work


Comment on Re: Problem while Data Extraction
Select or Download Code
Re^2: Problem while Data Extraction
by jpvinny28 (Initiate) on Dec 04, 2012 at 04:11 UTC

    Thank You guys.. YOU GUYS ARE AWESOME.. :)

    I improvised your previous code(Although not efficient as yours).. and was able to do it.. THANKS A LOT..

    while (<INFILE>) { chomp($_); my @parts = split /(\|[^\|]*\|)/; for my $part (@parts) { if ($part =~ /\|(.*)\|/) { $part=~s/\|//gi; $part=~ tr/ //ds; print ($part); } else { my $hex = ascii_to_hex($part); print ($hex); } } print("\n"); }

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (10)
As of 2015-07-06 21:58 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 (83 votes), past polls