Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: DBI converting hex values

by samtregar (Abbot)
on Nov 02, 2006 at 18:35 UTC ( #581943=note: print w/ replies, xml ) Need Help??


in reply to DBI converting hex values

If you can't convince DBI to leave your hex value alone you can always convert it back:

$a = "Paul"; $a =~ s!(.)!sprintf("%02x", ord($1))!eg; print "0x$a";

I'm sure there's a more clever way to do that with unpack, but I'm way too lazy to figure it out!

-sam


Comment on Re: DBI converting hex values
Download Code
Re^2: DBI converting hex values
by shmem (Canon) on Nov 02, 2006 at 18:52 UTC
    From Saints in our Book: "..and remember there are a lot of things monks are supposed to be but lazy is not one of them" :-)
    perl -le ' print "0x",unpack "H*",pack "A*","Paul"' 0x5061756c

    --shmem

    _($_=" "x(1<<5)."?\n".q·/)Oo.  G°\        /
                                  /\_¯/(q    /
    ----------------------------  \__(m.====·.(_("always off the crowd"))."·
    ");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}

      You might want to be more lazy and skip the pack "A*". (:

      - tye        

        Darn, you're right... do { print ((my $hubris = $hubris) >>= 1)} for $this_one :-)

        --shmem

Re^2: DBI converting hex values
by Sprad (Hermit) on Nov 02, 2006 at 18:58 UTC
    The problem, though, is that this DBI call is part of a larger module that encapsulates DB access for some tools. It's another layer on top of DBI. My layer doesn't know which items were formerly hex and which were strings all along, so I can't blindly convert.

    I could convert, though, if there were a way to know what data I was getting back. That might be another way to tackle the problem, but I'm not sure how to do that either. All I've done so far is just hand back the result array, which works great for everything except these fields.

    ---
    A fair fight is a sign of poor planning.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (6)
As of 2014-07-12 07:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    When choosing user names for websites, I prefer to use:








    Results (238 votes), past polls