From geoff at gmgsolutions.com.au Wed Jun 6 06:24:18 2007 From: geoff at gmgsolutions.com.au (Geoffrey Wood) Date: Wed, 6 Jun 2007 23:24:18 +1000 Subject: [Brisbane-pm] regex syntax - data extraction Message-ID: <001b01c7a83d$fca1c4c0$2800a8c0@DellD620> Hi all Trying to work out how to extract both hexadecimal values(as numeric) and string text (alphanumeric+spaces) from the string variables such as below. String snippet: 0504050000002a000022c402000000000009556e69742038393030000000007fffffff000120 000f30303031303831373330333335303000000022c502000000000009556e69742038393031 000000007fffffff000120000f30303031303831373330333335373000000022c60200000000 0009556e69742038393032000000007fffffff000120000f3030303130383137333033333833 30 Wanted data: Green - 3 byte Hex value Blue - string length Red - string 8900 'Unit 8900' '000108173033500' 8901 'Unit 8901' '000108173033570' 8902 'Unit 8902' '000108173033830' Any help appreciated. Kind regards, Geoffrey Wood Technical Director GMG Solutions Pty Ltd m: +61 4 1514 8448 f: +61 7 5571 2877 e: geoff at gmgsolutions.com.au w: www.gmgsolutions.com.au -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.pm.org/pipermail/brisbane-pm/attachments/20070606/870ab300/attachment.html From merlyn at stonehenge.com Wed Jun 6 15:10:07 2007 From: merlyn at stonehenge.com (Randal L. Schwartz) Date: Wed, 06 Jun 2007 15:10:07 -0700 Subject: [Brisbane-pm] coming to your town after SAGE-AU Message-ID: <86sl94loow.fsf@blue.stonehenge.com> I'll be in brisvegas the evening of 28 jul to the morning of 3 aug, immediately following the SAGE-AU in Sydney. I'd be happy to do a tech presentation, but if you have a social meeting that you could reconfigure to include me, please do. As far as I know, I'm only formally booked for activity during the day on the 30th and 31st, so any evening that doesn't lead into one of those should be free. Any takers? -- Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095 Perl/Unix/security consulting, Technical writing, Comedy, etc. etc. See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training! From geoff at gmgsolutions.com.au Wed Jun 6 15:55:05 2007 From: geoff at gmgsolutions.com.au (Geoffrey Wood) Date: Thu, 7 Jun 2007 08:55:05 +1000 Subject: [Brisbane-pm] Brisbane-pm Digest, Vol 29, Issue 1 In-Reply-To: References: Message-ID: <000f01c7a88d$b9849f00$2800a8c0@DellD620> Sorry guys, wasn't thinking that text formatting would be suppressed (you can't see red, green, blue) Here is another way to look at it: Header Hex No L Alpha/Num string 0504050000002a000022c402000000000009556e69742038393030000000007fffffff000120 L Numeric string Hex No L Alpha/Num string 000f30303031303831373330333335303000000022c502000000000009556e69742038393031 L Numeric string Hex No 000000007fffffff000120000f30303031303831373330333335373000000022c60200000000 L Alpha/Num string L Numeric string 0009556e69742038393032000000007fffffff000120000f3030303130383137333033333833 30 Header- 3 Bytes Hex No- 3 Bytes L - String Length Hope this makes sense. ghw ---------------------------------------------------------------------- Message: 1 Date: Wed, 6 Jun 2007 23:24:18 +1000 From: "Geoffrey Wood" Subject: [Brisbane-pm] regex syntax - data extraction To: Message-ID: <001b01c7a83d$fca1c4c0$2800a8c0 at DellD620> Content-Type: text/plain; charset="us-ascii" Hi all Trying to work out how to extract both hexadecimal values(as numeric) and string text (alphanumeric+spaces) from the string variables such as below. String snippet: 0504050000002a000022c402000000000009556e69742038393030000000007fffffff000120 000f30303031303831373330333335303000000022c502000000000009556e69742038393031 000000007fffffff000120000f30303031303831373330333335373000000022c60200000000 0009556e69742038393032000000007fffffff000120000f3030303130383137333033333833 30 Wanted data: Green - 3 byte Hex value Blue - string length Red - string 8900 'Unit 8900' '000108173033500' 8901 'Unit 8901' '000108173033570' 8902 'Unit 8902' '000108173033830' Any help appreciated. Kind regards, Geoffrey Wood Technical Director GMG Solutions Pty Ltd m: +61 4 1514 8448 f: +61 7 5571 2877 e: geoff at gmgsolutions.com.au w: www.gmgsolutions.com.au -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.pm.org/pipermail/brisbane-pm/attachments/20070606/870ab300/attac hment.htm ------------------------------ _______________________________________________ Brisbane-pm mailing list Brisbane-pm at pm.org http://mail.pm.org/mailman/listinfo/brisbane-pm End of Brisbane-pm Digest, Vol 29, Issue 1 ****************************************** From Sarah.Smith at trolltech.com Wed Jun 6 17:11:42 2007 From: Sarah.Smith at trolltech.com (Sarah Smith) Date: Thu, 7 Jun 2007 10:11:42 +1000 Subject: [Brisbane-pm] coming to your town after SAGE-AU In-Reply-To: <86sl94loow.fsf@blue.stonehenge.com> References: <86sl94loow.fsf@blue.stonehenge.com> Message-ID: <200706071011.42136.Sarah.Smith@trolltech.com> On Thursday 07 June 2007 08:10, Randal L. Schwartz wrote: > I'll be in brisvegas the evening of 28 jul to the morning of 3 aug, > immediately following the SAGE-AU in Sydney. I'd be happy to do a tech > presentation, but if you have a social meeting that you could reconfigure > to include me, please do. As far as I know, I'm only formally booked for > activity during the day on the 30th and 31st, so any evening that doesn't > lead into one of those should be free. > > Any takers? Hi Randal, The Brisbane pm scene has been fairly quiet, although there are a few lurkers on this list who might be keen. I've previously organized a Perlmongers event or so here at my work and would be able to do so again, probably followed by dinner, if people are keen. Dinner could be either "go somewhere nearby afterwards" or "have pizza/takeaways/etc in our lunchroom" - the lunchroom is large. Perhaps the evening of 1 Aug or 2 Aug would be a good time? Rgds, -- Sarah Smith BSc MACS Senior Software Engineer Ph +61 7 321 999 06 x109 Trolltech (Australia) Pty Ltd From merlyn at stonehenge.com Thu Jun 7 10:32:47 2007 From: merlyn at stonehenge.com (Randal L. Schwartz) Date: Thu, 07 Jun 2007 10:32:47 -0700 Subject: [Brisbane-pm] coming to your town after SAGE-AU In-Reply-To: <200706071011.42136.Sarah.Smith@trolltech.com> (Sarah Smith's message of "Thu, 7 Jun 2007 10:11:42 +1000") References: <86sl94loow.fsf@blue.stonehenge.com> <200706071011.42136.Sarah.Smith@trolltech.com> Message-ID: <86lkevk6v4.fsf@blue.stonehenge.com> >>>>> "Sarah" == Sarah Smith writes: Sarah> Perhaps the evening of 1 Aug or 2 Aug would be a good time? I'm game for anything, as long as it's not a "school night" (the night before either of my two teaching days). I'd lean towards the first though, as I want to be sure to get a good sleep on the second because I'll be travelling BNE to SYD to HNL to LAX. Ugh. :) -- Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095 Perl/Unix/security consulting, Technical writing, Comedy, etc. etc. See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training! From erroneousbollock at gmail.com Thu Jun 7 19:25:03 2007 From: erroneousbollock at gmail.com (David Toso) Date: Fri, 8 Jun 2007 12:25:03 +1000 Subject: [Brisbane-pm] coming to your town after SAGE-AU Message-ID: On 6/7/07, Sarah Smith wrote: > The Brisbane pm scene has been fairly quiet, although there are a few > lurkers > on this list who might be keen. /me unlurks . I've previously organized a Perlmongers event or so here at my work and > would > be able to do so again, probably followed by dinner, if people are keen. Please count me in. -David Toso. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.pm.org/pipermail/brisbane-pm/attachments/20070608/a23612cb/attachment.html From merlyn at stonehenge.com Mon Jun 11 14:05:06 2007 From: merlyn at stonehenge.com (Randal L. Schwartz) Date: Mon, 11 Jun 2007 14:05:06 -0700 Subject: [Brisbane-pm] coming to your town after SAGE-AU In-Reply-To: <200706080234.l582YSxS029635@wraith.its.griffith.edu.au> (Anthony Thyssen's message of "Fri, 08 Jun 2007 12:34:28 +1000") References: <200706080234.l582YSxS029635@wraith.its.griffith.edu.au> Message-ID: <86lkeqcid9.fsf@blue.stonehenge.com> >>>>> "Anthony" == Anthony Thyssen writes: Anthony> Actually I have been offered to attend the tutorial, but am having Anthony> trouble finding what level it is aimed at. Basic -- no, Advanced - yes! One day llama, one day alpaca. Take both days in a row, and your head explodes! -- Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095 Perl/Unix/security consulting, Technical writing, Comedy, etc. etc. See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training! From David.Bussenschutt at qmtechnologies.com Mon Jun 11 16:19:29 2007 From: David.Bussenschutt at qmtechnologies.com (David Bussenschutt) Date: Tue, 12 Jun 2007 09:19:29 +1000 Subject: [Brisbane-pm] coming to your town after SAGE-AU Message-ID: <19F217C6E2CA304CBDFE4D8CB16CA14B0392DF97@exch-b01.qmtechnologies.com> Hi everyone! Firstly: /me unlurks too! Secondly: Randal, I'm in charge of about 14 perl programmers here at QM, and at least a few of them would like to meet you and hear what you've go to say ! Thirdly: Sarah, If you don't have a problem with maybe a 1/2 dozen or so more perl programmers, I think I can get that many to come too. I guess Wed 1st Aug sounds like it's the go - Time and place? (If that number is a problem let me know! - I can sponsor pizza if it helps?) Finally: Randal, don't underestimate Anthony's ability to "not explode" :-) Background: I occassionally teach a course I call "Intro to Perl" (ie 3 times!), and am a senior perl resource at QM. Anthony taught me just about everything I know about perl (starting in about 1999 I think!) .... and I think he's forgotten more than I ever knew! :-) Bright! David Bussenschutt IT Business Systems Manager QM Technologies QLD work: David.Bussenschutt at qmtechnologies.com personal: davidbuzz at gmail.com ph: 07 3013 5043 -----Original Message----- From: brisbane-pm-bounces+david.bussenschutt=qmtechnologies.com at pm.org [mailto:brisbane-pm-bounces+david.bussenschutt=qmtechnologies.com at pm.org ]On Behalf Of Randal L. Schwartz Sent: Tuesday, 12 June 2007 7:05 AM To: Anthony Thyssen Cc: brisbane-pm at pm.org Subject: Re: [Brisbane-pm] coming to your town after SAGE-AU >>>>> "Anthony" == Anthony Thyssen writes: Anthony> Actually I have been offered to attend the tutorial, but am having Anthony> trouble finding what level it is aimed at. Basic -- no, Advanced - yes! One day llama, one day alpaca. Take both days in a row, and your head explodes! -- Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095 Perl/Unix/security consulting, Technical writing, Comedy, etc. etc. See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training! _______________________________________________ Brisbane-pm mailing list Brisbane-pm at pm.org http://mail.pm.org/mailman/listinfo/brisbane-pm The message and any attachment is confidential and may be privileged or otherwise protected from disclosure. If you have received it by mistake please let us know by reply and then delete it from your system; you should not copy the message or disclose its contents to anyone. From Sarah.Smith at trolltech.com Mon Jun 11 16:46:49 2007 From: Sarah.Smith at trolltech.com (Sarah Smith) Date: Tue, 12 Jun 2007 09:46:49 +1000 Subject: [Brisbane-pm] coming to your town after SAGE-AU In-Reply-To: <19F217C6E2CA304CBDFE4D8CB16CA14B0392DF97@exch-b01.qmtechnologies.com> References: <19F217C6E2CA304CBDFE4D8CB16CA14B0392DF97@exch-b01.qmtechnologies.com> Message-ID: <200706120946.49942.Sarah.Smith@trolltech.com> On Tuesday 12 June 2007 09:19, David Bussenschutt wrote: > Hi everyone! > > Firstly: > /me unlurks too! > > Secondly: > Randal, I'm in charge of about 14 perl programmers here at QM, and at least > a few of them would like to meet you and hear what you've go to say ! We use Perl for a lot of peripheral stuff here, tho' our products are in C++. > Thirdly: > Sarah, If you don't have a problem with maybe a 1/2 dozen or so more perl > programmers, I think I can get that many to come too. I guess Wed 1st Aug > sounds like it's the go - Time and place? (If that number is a problem let > me know! - I can sponsor pizza if it helps?) Numbers are not a problem - we can accommodate about 40. Chipping in for pizza could be good. I can get our facilities mgr to buy in some extra drinks and make sure there's a data projector available. I just have to do a sales job on my boss. :-) As soon as its definite will confirm - but yes Wed 1 August sounds good, probably 6pm start. > Finally: > Randal, don't underestimate Anthony's ability to "not explode" :-) > Background: I occassionally teach a course I call "Intro to Perl" (ie 3 > times!), and am a senior perl resource at QM. Anthony taught me just > about everything I know about perl (starting in about 1999 I think!) .... > and I think he's forgotten more than I ever knew! :-) Bright! I ran a Perl tutorial seminar here for our guys and had a full house, so I think there's interest here too. > > > David Bussenschutt > IT Business Systems Manager > QM Technologies QLD > work: David.Bussenschutt at qmtechnologies.com > personal: davidbuzz at gmail.com > ph: 07 3013 5043 > > > -----Original Message----- > From: brisbane-pm-bounces+david.bussenschutt=qmtechnologies.com at pm.org > [mailto:brisbane-pm-bounces+david.bussenschutt=qmtechnologies.com at pm.org > ]On Behalf Of Randal L. Schwartz > Sent: Tuesday, 12 June 2007 7:05 AM > To: Anthony Thyssen > Cc: brisbane-pm at pm.org > Subject: Re: [Brisbane-pm] coming to your town after SAGE-AU > > >>>>> "Anthony" == Anthony Thyssen writes: > > Anthony> Actually I have been offered to attend the tutorial, but am having > Anthony> trouble finding what level it is aimed at. Basic -- no, Advanced > - yes! > > One day llama, one day alpaca. Take both days in a row, and your head > explodes! -- Sarah Smith BSc MACS Senior Software Engineer Ph +61 7 321 999 06 x109 Trolltech (Australia) Pty Ltd From merlyn at stonehenge.com Mon Jun 11 17:03:08 2007 From: merlyn at stonehenge.com (Randal L. Schwartz) Date: Mon, 11 Jun 2007 17:03:08 -0700 Subject: [Brisbane-pm] coming to your town after SAGE-AU In-Reply-To: <200706120946.49942.Sarah.Smith@trolltech.com> (Sarah Smith's message of "Tue, 12 Jun 2007 09:46:49 +1000") References: <19F217C6E2CA304CBDFE4D8CB16CA14B0392DF97@exch-b01.qmtechnologies.com> <200706120946.49942.Sarah.Smith@trolltech.com> Message-ID: <86ps4259ab.fsf@blue.stonehenge.com> >>>>> "Sarah" == Sarah Smith writes: Sarah> As soon as its definite will confirm - but yes Wed 1 August sounds Sarah> good, probably 6pm start. Sounds good to me. But wait.. I'm already teaching for two days. I had been thinking this would just be a social gathering in the evening. Are we on the same page? I mean, I can certainly be entertaining, etc, but mostly I just wanna hang out and have fun meeting fellow Perl dudes and dudettes. However, if you really do want a technical meetup, I can probably be convinced to drag along my laptop and show some slides for an hour or two. -- Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095 Perl/Unix/security consulting, Technical writing, Comedy, etc. etc. See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training! From David.Bussenschutt at qmtechnologies.com Mon Jun 11 17:30:31 2007 From: David.Bussenschutt at qmtechnologies.com (David Bussenschutt) Date: Tue, 12 Jun 2007 10:30:31 +1000 Subject: [Brisbane-pm] coming to your town after SAGE-AU Message-ID: <19F217C6E2CA304CBDFE4D8CB16CA14B0392DF9D@exch-b01.qmtechnologies.com> Randal, Informal/Social/random is fine by me (I'm a big fan!), but I think others might get more out of it if you could give them maybe 10 minutes (not 2 hours - gosh!) on "something cool about perl". :-) We're talking perl geeks here - most of them like tech just for the sake of tech! Buzz aka David Bussenschutt QM Technologies David.Bussenschutt at qmtechnologies.com ph: 07 3013 5043 -----Original Message----- From: Randal L. Schwartz [mailto:merlyn at stonehenge.com] Sent: Tuesday, 12 June 2007 10:03 AM To: Sarah Smith Cc: David Bussenschutt; Anthony Thyssen; brisbane-pm at pm.org Subject: Re: [Brisbane-pm] coming to your town after SAGE-AU >>>>> "Sarah" == Sarah Smith writes: Sarah> As soon as its definite will confirm - but yes Wed 1 August sounds Sarah> good, probably 6pm start. Sounds good to me. But wait.. I'm already teaching for two days. I had been thinking this would just be a social gathering in the evening. Are we on the same page? I mean, I can certainly be entertaining, etc, but mostly I just wanna hang out and have fun meeting fellow Perl dudes and dudettes. However, if you really do want a technical meetup, I can probably be convinced to drag along my laptop and show some slides for an hour or two. -- Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095 Perl/Unix/security consulting, Technical writing, Comedy, etc. etc. See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training! The message and any attachment is confidential and may be privileged or otherwise protected from disclosure. If you have received it by mistake please let us know by reply and then delete it from your system; you should not copy the message or disclose its contents to anyone. From Sarah.Smith at trolltech.com Mon Jun 11 17:54:23 2007 From: Sarah.Smith at trolltech.com (Sarah Smith) Date: Tue, 12 Jun 2007 10:54:23 +1000 Subject: [Brisbane-pm] coming to your town after SAGE-AU In-Reply-To: <86ps4259ab.fsf@blue.stonehenge.com> References: <19F217C6E2CA304CBDFE4D8CB16CA14B0392DF97@exch-b01.qmtechnologies.com> <200706120946.49942.Sarah.Smith@trolltech.com> <86ps4259ab.fsf@blue.stonehenge.com> Message-ID: <200706121054.23867.Sarah.Smith@trolltech.com> On Tuesday 12 June 2007 10:03, Randal L. Schwartz wrote: > >>>>> "Sarah" == Sarah Smith writes: > > Sarah> As soon as its definite will confirm - but yes Wed 1 August sounds > Sarah> good, probably 6pm start. > > Sounds good to me. But wait.. I'm already teaching for two days. I had > been thinking this would just be a social gathering in the evening. Are we > on the same page? I mean, I can certainly be entertaining, etc, but mostly > I just wanna hang out and have fun meeting fellow Perl dudes and dudettes. > However, if you really do want a technical meetup, I can probably be > convinced to drag along my laptop and show some slides for an hour or two. Ooops - my bad. The last PM meetup here we had a presentation, then nosh afterward. /me leapt to assumption... But if you have some slides already and aren't all talked out it would be great to have you present on whatever you feel like. Would get me out of trouble because I am halfway thru selling it to our VP Engineering here on the basis it'd be the same format as last time. It would only need to be a short presentation - certainly not more than an hour. I can negotiate for higher grade nosh, maybe even some libations :-) I'm going to argue for access to our pool table as well. Your call. Rgds, -- Sarah Smith BSc MACS Senior Software Engineer Ph +61 7 321 999 06 x109 Trolltech (Australia) Pty Ltd From barry at bquotes.com Tue Jun 12 03:02:19 2007 From: barry at bquotes.com (Barry Downes) Date: Tue, 12 Jun 2007 20:02:19 +1000 Subject: [Brisbane-pm] Brisbane-pm Digest, Vol 29, Issue 1 In-Reply-To: <000f01c7a88d$b9849f00$2800a8c0@DellD620> References: <000f01c7a88d$b9849f00$2800a8c0@DellD620> Message-ID: <466E6F2B.5010307@bquotes.com> Hey Geoffrey, I didn't see a response to your question yet. I hope this isn't so late as to be useless.. I find it easier in Perl to extract data from binary strings than hex strings like yours, so I'd convert it to binary first using "pack". Then I'd use "substr" and "unpack" to extract and interpret data. You'll probably find the Perl documentation for "pack" particularly helpful. It packs Perl data items into compact binary representations as used by lower-level languages and systems, and unpack does the opposite. The binary data is stored in Perl scalars. Perl's pretty good at handling binary because Perl scalars can store any 8-bit character, including the null character, without issues. Probably knowing the right tools is enough, but here's a few lines of code showing how you might use them: #!/usr/bin/perl use strict; use warnings; # the original hex data my $hex = '0504050000002a000022c402000000000009556e69742038393030000000007fffffff000120000f30303031303831373330333335303000000022c502000000000009556e69742038393031000000007fffffff000120000f30303031303831373330333335373000000022c602000000000009556e69742038393032000000007fffffff000120000f303030313038313733303333383330'; # convert to binary (because it's easier to work with) my $bin = pack('H*', $hex); my $val = get3Bytes($bin, 8); my $str1 = getString($bin, 17); my $str2 = getString($bin, 39); print "$val\n"; print "$str1\n"; print "$str2\n"; sub get3Bytes { # extract a 3-byte value my ($bin, $ofs) = @_; # grab 3 bytes and pad with a leading 00 byte my $str = "\x00" . substr($bin, $ofs, 3); # unpack as a "network-order" 4-byte integer my $val = unpack('N', $str); return $val; } sub getString { # extract a string with 1-byte length my ($bin, $ofs) = @_; # interpret the length as a 1-byte unsigned integer my $size = unpack('C', substr($bin, $ofs, 1)); # extract a string of the indicated length my $string = substr($bin, $ofs+1, $size); return $string; } Geoffrey Wood wrote: > Sorry guys, wasn't thinking that text formatting would be suppressed (you > can't see red, green, blue) > > Here is another way to look at it: > > Header Hex No L Alpha/Num string > 0504050000002a000022c402000000000009556e69742038393030000000007fffffff000120 > L Numeric string Hex No L Alpha/Num string > 000f30303031303831373330333335303000000022c502000000000009556e69742038393031 > L Numeric string Hex No > 000000007fffffff000120000f30303031303831373330333335373000000022c60200000000 > L Alpha/Num string L Numeric string > 0009556e69742038393032000000007fffffff000120000f3030303130383137333033333833 > 30 > > Header- 3 Bytes > Hex No- 3 Bytes > L - String Length > > Hope this makes sense. > > ghw > ---------------------------------------------------------------------- > > Message: 1 > Date: Wed, 6 Jun 2007 23:24:18 +1000 > From: "Geoffrey Wood" > Subject: [Brisbane-pm] regex syntax - data extraction > To: > Message-ID: <001b01c7a83d$fca1c4c0$2800a8c0 at DellD620> > Content-Type: text/plain; charset="us-ascii" > > Hi all > > Trying to work out how to extract both hexadecimal values(as numeric) and > string text (alphanumeric+spaces) from the string variables such as below. > > String snippet: > > 0504050000002a000022c402000000000009556e69742038393030000000007fffffff000120 > 000f30303031303831373330333335303000000022c502000000000009556e69742038393031 > 000000007fffffff000120000f30303031303831373330333335373000000022c60200000000 > 0009556e69742038393032000000007fffffff000120000f3030303130383137333033333833 > 30 > > Wanted data: > Green - 3 byte Hex value > Blue - string length > Red - string > > 8900 'Unit 8900' '000108173033500' > 8901 'Unit 8901' '000108173033570' > 8902 'Unit 8902' '000108173033830' > > Any help appreciated. > > Kind regards, > Geoffrey Wood > Technical Director > GMG Solutions Pty Ltd > m: +61 4 1514 8448 > f: +61 7 5571 2877 > e: geoff at gmgsolutions.com.au > w: www.gmgsolutions.com.au > > -------------- next part -------------- > An HTML attachment was scrubbed... > URL: > http://mail.pm.org/pipermail/brisbane-pm/attachments/20070606/870ab300/attac > hment.htm > > ------------------------------ > > _______________________________________________ > Brisbane-pm mailing list > Brisbane-pm at pm.org > http://mail.pm.org/mailman/listinfo/brisbane-pm > > End of Brisbane-pm Digest, Vol 29, Issue 1 > ****************************************** > _______________________________________________ > Brisbane-pm mailing list > Brisbane-pm at pm.org > http://mail.pm.org/mailman/listinfo/brisbane-pm > > From geoff at gmgsolutions.com.au Tue Jun 12 07:49:56 2007 From: geoff at gmgsolutions.com.au (Geoffrey Wood) Date: Wed, 13 Jun 2007 00:49:56 +1000 Subject: [Brisbane-pm] regex syntax - data extraction In-Reply-To: <466E6F2B.5010307@bquotes.com> References: <000f01c7a88d$b9849f00$2800a8c0@DellD620> <466E6F2B.5010307@bquotes.com> Message-ID: <004a01c7ad00$f1bc8e60$2800a8c0@DellD620> Thanks Barry for your input. I will start with your code and try it out. I'm new to pm and Perl and wasn't sure if I had posted my request correctly with pm. A friend told me to try out Perl for a proof of concept idea I wanted to test out. I have now proved my concept but am at a stage where I would need some professional Perl help to make a commercial product... Anyone interested in taking a look at my project? cheers Geoff Wood -----Original Message----- From: Barry Downes [mailto:barry at bquotes.com] Sent: Tuesday, June 12, 2007 8:02 PM To: Geoffrey Wood Cc: brisbane-pm at pm.org Subject: Re: [Brisbane-pm] Brisbane-pm Digest, Vol 29, Issue 1 Hey Geoffrey, I didn't see a response to your question yet. I hope this isn't so late as to be useless.. I find it easier in Perl to extract data from binary strings than hex strings like yours, so I'd convert it to binary first using "pack". Then I'd use "substr" and "unpack" to extract and interpret data. You'll probably find the Perl documentation for "pack" particularly helpful. It packs Perl data items into compact binary representations as used by lower-level languages and systems, and unpack does the opposite. The binary data is stored in Perl scalars. Perl's pretty good at handling binary because Perl scalars can store any 8-bit character, including the null character, without issues. Probably knowing the right tools is enough, but here's a few lines of code showing how you might use them: #!/usr/bin/perl use strict; use warnings; # the original hex data my $hex = '0504050000002a000022c402000000000009556e69742038393030000000007fffffff00012 0000f30303031303831373330333335303000000022c502000000000009556e6974203839303 1000000007fffffff000120000f30303031303831373330333335373000000022c6020000000 00009556e69742038393032000000007fffffff000120000f303030313038313733303333383 330'; # convert to binary (because it's easier to work with) my $bin = pack('H*', $hex); my $val = get3Bytes($bin, 8); my $str1 = getString($bin, 17); my $str2 = getString($bin, 39); print "$val\n"; print "$str1\n"; print "$str2\n"; sub get3Bytes { # extract a 3-byte value my ($bin, $ofs) = @_; # grab 3 bytes and pad with a leading 00 byte my $str = "\x00" . substr($bin, $ofs, 3); # unpack as a "network-order" 4-byte integer my $val = unpack('N', $str); return $val; } sub getString { # extract a string with 1-byte length my ($bin, $ofs) = @_; # interpret the length as a 1-byte unsigned integer my $size = unpack('C', substr($bin, $ofs, 1)); # extract a string of the indicated length my $string = substr($bin, $ofs+1, $size); return $string; } Geoffrey Wood wrote: > Sorry guys, wasn't thinking that text formatting would be suppressed (you > can't see red, green, blue) > > Here is another way to look at it: > > Header Hex No L Alpha/Num string > 0504050000002a000022c402000000000009556e69742038393030000000007fffffff000120 > L Numeric string Hex No L Alpha/Num string > 000f30303031303831373330333335303000000022c502000000000009556e69742038393031 > L Numeric string Hex No > 000000007fffffff000120000f30303031303831373330333335373000000022c60200000000 > L Alpha/Num string L Numeric string > 0009556e69742038393032000000007fffffff000120000f3030303130383137333033333833 > 30 > > Header- 3 Bytes > Hex No- 3 Bytes > L - String Length > > Hope this makes sense. > > ghw > ---------------------------------------------------------------------- > > Message: 1 > Date: Wed, 6 Jun 2007 23:24:18 +1000 > From: "Geoffrey Wood" > Subject: [Brisbane-pm] regex syntax - data extraction > To: > Message-ID: <001b01c7a83d$fca1c4c0$2800a8c0 at DellD620> > Content-Type: text/plain; charset="us-ascii" > > Hi all > > Trying to work out how to extract both hexadecimal values(as numeric) and > string text (alphanumeric+spaces) from the string variables such as below. > > String snippet: > > 0504050000002a000022c402000000000009556e69742038393030000000007fffffff000120 > 000f30303031303831373330333335303000000022c502000000000009556e69742038393031 > 000000007fffffff000120000f30303031303831373330333335373000000022c60200000000 > 0009556e69742038393032000000007fffffff000120000f3030303130383137333033333833 > 30 > > Wanted data: > Green - 3 byte Hex value > Blue - string length > Red - string > > 8900 'Unit 8900' '000108173033500' > 8901 'Unit 8901' '000108173033570' > 8902 'Unit 8902' '000108173033830' > > Any help appreciated. > > Kind regards, > Geoffrey Wood > Technical Director > GMG Solutions Pty Ltd > m: +61 4 1514 8448 > f: +61 7 5571 2877 > e: geoff at gmgsolutions.com.au > w: www.gmgsolutions.com.au > > -------------- next part -------------- > An HTML attachment was scrubbed... > URL: > http://mail.pm.org/pipermail/brisbane-pm/attachments/20070606/870ab300/attac > hment.htm > > ------------------------------ > > _______________________________________________ > Brisbane-pm mailing list > Brisbane-pm at pm.org > http://mail.pm.org/mailman/listinfo/brisbane-pm > > End of Brisbane-pm Digest, Vol 29, Issue 1 > ****************************************** > _______________________________________________ > Brisbane-pm mailing list > Brisbane-pm at pm.org > http://mail.pm.org/mailman/listinfo/brisbane-pm > > From Sarah.Smith at trolltech.com Tue Jun 12 18:15:18 2007 From: Sarah.Smith at trolltech.com (Sarah Smith) Date: Wed, 13 Jun 2007 11:15:18 +1000 Subject: [Brisbane-pm] PerlMongers get together 1 August Message-ID: <200706131115.18356.Sarah.Smith@trolltech.com> Hi Perlfolk, Here's an official invite to a PerlMongers get together: When: Wed 1 August 2007, 6:00pm Where:Trolltech, Lvl 1, 53 Brandl St Brisbane Technology Park, Eight Mile Plains What: Presentation by Randal Schwartz approx 6:15-7pm General get together with beer, wine, finger food, and pizza afterwards, Sponsors: Trolltech, and QM Technologies Directions: by car, come southbound on Logan Rd from the intersection with Miles Platting Rd, and take the first left after the service station. By bus, take the 111 from the city to eight mile plains, walk (approx 10 minutes) along Miles Platting and turn down McKechnie Drive. http://www.zoomin.com.au/australia/qld/brisbane/eight+mile+plains/brandl+street/53/ Help: Contact me, Sarah Smith, cell +61 416 045 401 (or locally 0416 045 401) See you all there! Rgds, -- Sarah Smith BSc MACS Senior Software Engineer Ph +61 7 321 999 06 x109 Trolltech (Australia) Pty Ltd