Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: Problem while Data Extraction

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


in reply to Problem while Data Extraction

Don't turn off warnings, instead understand and fix the warnings.

Don't use prototype subs - they don't do what you think and will probably bite you.

If I understand what you want to do correctly the following should help:

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

Prints:

01234.dropbox.com User-Agent:Google Desktop
True laziness is hard work


Comment on Re: Problem while Data Extraction
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (7)
As of 2014-08-29 17:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (283 votes), past polls