in reply to Re: Re: SQLServer varbinary headache
in thread SQLServer varbinary headache

TMTOWTDI

Well, the main difference is that I sequestered the convert-blob-to-long-hex-string dance off in its own subroutine (bin2hex) and then applied it to those columns that needed converting (just one column this time, but there might be other columns in similar code in the future, so you could reuse the code).

As far as the way we both did the blob-to-hex-string conversion, there are some things that I think your version does better and some that mine does better. Basically, I'm not too comfortable with pack/unpack, so I tend to use it less than I really should. I am, however, very comfortable with map and so will use that in preference to a for loop when I feel it makes sense. (I still think that the corrected bin2hex I posted, based on what Util said in this same thread, is really the best option)

-- @/=map{[/./g]}qw/.h_nJ Xapou cets krht ele_ r_ra/; map{y/X_/\n /;print}map{pop@$_}@/for@/

Replies are listed 'Best First'.
Re: Re: Re: Re: SQLServer varbinary headache
by bfdi533 (Friar) on Apr 26, 2004 at 22:38 UTC

    Right you are!

    I, on the other hand, have no clue how map works no matter how many times I read through its description. So, I tend to use the code from the previous programming incarnations I know (C, etc.). I will definitely use your subroutine in my next rev. as it is definitely more readable and maintainable.

    Ed