I am having a tough time figuring out how to make something work. I have a string:$String = "68 74 74 70 3a 2f 2f 31 36 30 2e 31 35 33 2e 34 33 2f 00 00 00 00 00 18"This string is hex, but perl thinks it's decimal when it gets assigned like that because when I try to unpack it into ascii, I get the wrong ascii characters.Does someone know a good way to convert this string into a string interpreted as hex so that I can convert it into an ascii string?thanks
8/4/2009 5:44:25 PM
1) http://perldoc.perl.org/functions/unpack.html1) http://perldoc.perl.org/functions/split.html2) http://perldoc.perl.org/functions/hex.html?[Edited on August 4, 2009 at 5:51 PM. Reason : that's not what unpack does, apparently][Edited on August 4, 2009 at 6:01 PM. Reason : actually, nm. I don't know much about pack/unpack but it looks like you could make unpack do it...]
8/4/2009 5:49:36 PM
I'm sorry but since this question doesn't have anything to do with administering a webserver or answering tech-support questions, you'll have a hard time getting any productive responses.However, I am here to help. Check out the 'pack' command:http://perl.active-venture.com/pod/func/pack.html
8/4/2009 7:08:40 PM
Did you even read it, I'm trying to use pack already. The problem is that the string is a decimal representation (as far as perl is concerned) but is hex (as far as what I know it is).I can't pack it into hex first, it is hex so I'll get the wrong values. I also can't convert is straight to ascii, perl thinks it's decimal, so I'll get the wrong values.
8/4/2009 9:06:17 PM
unpack could theoretically do it, but it would help if the string was more like 0xAA0x12etc, etc. The string you have looks like it is the RESULT of the pack command, converting ASCII characters into a hex string. If that was the case, unpack will do it, I just couldn't figure out how to account for the space in between the values.So using pack again is closest to the opposite of what needs to happen.Like I linked, you could use split to slice up the string and get an array, and then use hex to get the integers corresponding to the proper ASCII values for each character. I haven't tried this, but it should work. There is, however, probably some super leet one line way to do it with a regex, but split/hex would at least do what you want.
8/4/2009 9:23:51 PM
Look, you're a 22 yr old sr in computer science. You shouldn't have to turn to the wolfweb for this.
8/4/2009 9:26:09 PM
^^ Yeah, good call, I can unpack it with the hex() call and it works perfectly. ^ I don't know what illusionary world you live in, but the NC State computer science department doesn't teach everything you need to know about anything, much less perl and the built in functions that help solve problems you may have
8/4/2009 9:51:08 PM
pack("H*", join '', split / /, $string) is the one liner that takes care of it, fyi
8/5/2009 9:01:20 AM
Know, the CSC department hasn't figured out a way to implant the knowledge of all languages into your brain, but they definitely should have you to the point where you can google around, try shit out, and read documentation. I know the department is mildly lackluster, but it isn't that.
8/5/2009 9:09:07 AM
lol, wow. I guess pack is what you want to use. Can you do the same thing with unpack? To me that string looks like something that's was generated from an ASCII string with pack - packing each character into hex and separating with a space.
8/5/2009 10:55:34 AM
I feel vindicated. Thx for the update AstralEngine
8/5/2009 11:25:05 AM
My new blackberry Tour kicks the Perl's ass.
8/5/2009 11:36:42 AM
It was not generated with pack, it's the hex returned from a SCSI target^x4 Fantastic, Fail Boat's idea of "what you're supposed to get out of college" is a mediocre skill at searching google for the answers to your questions. I, for one, feel that NC State has succeeded at this menial task...........Oh wait, I could already search google for this shit, and have been. There's nothing wrong with asking people who may be more knowledgeable for the answer, though
8/5/2009 2:04:19 PM
Excellent, not only can you not think for yourself, but your reading comprehension is terrible. Guys like you make me glad that I somehow was attracted to ECE and not CSC.
8/5/2009 3:15:20 PM
How long have you been at your current position?
8/5/2009 3:36:40 PM
I'm not sure what at all that has to be with being too inept to figure out the most simple of problems.What stellar line of work do you do?
8/5/2009 3:56:48 PM
And I'm not sure what anything you've posted in this thread has to do with figuring out the best way to parse/convert that string in Perl. Asking something that you could figure out with Google isn't always retarded - it's not like you can have a real discussion about a question with a search engine.But since we figured out the Perl question, what should the thread be about now? The CSC department, asking questions in tech talk, your unemployment, or my job?[Edited on August 5, 2009 at 4:29 PM. Reason : grammar]
8/5/2009 4:28:38 PM
The guy bitching about reading comprehension is also the guy who showed on this page he didn't know the different between "Know" and "No".Lets just chalk it up to sand lodged some place pretty uncomfortable.Also, everyone knows that dakota_man is a successful restauranteur.
8/5/2009 4:38:22 PM
Aw, shucks.
8/5/2009 4:53:01 PM
Since you missed the memo Stein, here it is againmessage_topic.aspx?topic=570112
8/5/2009 11:07:46 PM
Dude, I'm not going to read an ignored thread you post so that I can understand your terrible posting habits.That's asking me to believe that somehow despite constant shit posts, your threads are going to come up diamonds.
8/5/2009 11:34:58 PM
You read the thread dipshit.
8/5/2009 11:35:58 PM
Actually, I clicked the link, saw you were the first poster and closed it.You might have actually tricked me into reading it if you'd used one of your like other aliases!
8/5/2009 11:40:27 PM
You're a terribly boring troll.
8/5/2009 11:50:43 PM
No wonder you're 40 and unemployed. I, on the other hand, have a job this summer with a great company and will more than likely have a full time position here after graduation. Perhaps my ability to communicate and willingness to not only seek out, but also share, information matched with my not-troll personality (read "not fail boat") make me a considerably better candidate in the job market. I bet you go out of your way to be a dick in real life, too... Explains a lot about your current jobless situation.Good luck with that
8/6/2009 10:17:14 AM
I managed guys like you at my last job. Just sayin.
8/6/2009 10:19:53 AM
You also lost your last job.Just sayin
8/6/2009 10:26:05 AM
8/6/2009 10:29:12 AM
ahahahaha holy shit this mug dropped "ivory basement"dakota, i love youi have missed you so much
8/6/2009 10:36:15 AM
you had me at 'ahahahaha'
8/6/2009 10:45:32 AM
8/6/2009 10:54:49 AM
You mean the 16.5% of YOU
8/6/2009 10:57:57 AM
I'm fairly certain when I said us I meant us.
8/6/2009 11:00:53 AM
I just wanted to make it clear that I'm not in the fail boat with you.
8/6/2009 11:06:37 AM
8/6/2009 11:07:15 AM
You mean they pay for crowd sourced content there? Seems like the only one who makes money on that is Joel and co.
8/6/2009 11:15:56 AM
Since the topic has changed for new ways to help Fail Boat make money, I decided to post this thread for you.message_topic.aspx?topic=559587Hopefully the money you earn will help pay for your operation
8/6/2009 11:22:46 AM
8/6/2009 11:48:46 AM
The whole point is, he didn't seem to do any sort of rudimentary debug or problem solving to figure out what perl was spitting back at him and why it was different.
8/6/2009 12:12:02 PM
Just because I had asked the question without a list of stuff I had already tried doesn't mean I haven't tried stuff.The string WAS hex. It was a STRING of hex characters... I'm not entirely sure how that's different, or how you wouldn't have gotten my meaning unless you're an idiot.when I chopped it down to just 68, it gave me the ascii character associated with DECIMAL 68 and not HEX 68, which is where the whole description of the problem was going.when I read the documentation, it seemed to me like pack("H*"...) would pack the values it took INTO hex, which is not what I thought I wanted at the time, since I thought Perl would have tried to pack decimal 68 into it's hex representation. Which, as I've learned now, was wrong.I hope you were more helpful to the people you "managed" at your old job, because this "you should be able to figure out everything on your own without asking for anyone's help" attitude is definitely not the way you help people be more productive. I hope you don't bring that up in interviews, because no wonder you haven't been rehired.[Edited on August 6, 2009 at 12:44 PM. Reason : ]
8/6/2009 12:37:05 PM
8/6/2009 2:28:19 PM
I like how Chance always touts his ECE degree like it makes him the champion of Tech Talk or something. Dude always takes potshots at software and web dev people (I think he called it a war or something once) but he still can't find a job. I love this guy.
8/6/2009 8:40:42 PM
My ECE degree has nothing to do with this thread. The only reason it was mentioned is to point out that when those topics come up, I comment on them.If similar guys rolled up in this thread doing stupid circuit shit, they'd get called out as well. Ask joenumbers how well his voltage regulator question he had for a candidate at a career fair once went when he posted it here. Quinn knows what I'm talking about.And I think it's great how you guys keep talking shit about my job situation in the worst downturn in 70 years. The funny thing is, I'll be employed in another month or so again making more money than you software guys can sniff at.
8/6/2009 9:02:17 PM
This thread should've ended with the third post, when I pointed AstralEngine to the pack command.dakota_man: its ok that you're not a perl guru. no one's judging you for it, and you shouldn't judge the language or the documentation for such a nitpicky thing. learning curves are learning curves. chance: srsly?
8/6/2009 9:10:49 PM
8/6/2009 9:13:40 PM
He was already working with pack you stupid son of a bitch. Get the fuck out with your standard weak trolling you incompetent fuck.^ I'm sorry you can't comprehend a perfectly understandable sentence.[Edited on August 6, 2009 at 9:14 PM. Reason : .]
8/6/2009 9:13:58 PM
Oh, I get it, you're going to be making more money than me when you get a job "in a month or so."Cool, you'll be needing to play some catch-up anyway.
8/6/2009 9:15:20 PM
yea, "in a month or so".... lolgood catch
8/6/2009 9:16:52 PM
No, my starting salary will be more than you're making now. The money I made in 2008 is more than you made. The money I make in 2010 will be more than you make.It's the benefit of getting through the ECE curriculum.
8/6/2009 9:24:24 PM
Another benefit appears to be the transformation into a raging, money-grubbing douchebag.[Edited on August 6, 2009 at 9:26 PM. Reason : and lololol at "will be"]
8/6/2009 9:25:52 PM