http://qs321.pair.com?node_id=308622


in reply to fast string parser: regex versus substr

Thanks all,

I came up with.

sub dopack { foreach my $i ( 0..$#data ) { my $line=$data[$i]; my ($jcpu,$j,$s)=(unpack('@2A16A40A232A16', $line))[0,1,3]; warn "$jcpu $j $s"; # ..store the values in a hash, but that is not important here } }
And it won the benchmark competition :-)

I never really understood pack and unpack, but it am getting to like it.
---------------------------
Dr. Mark Ceulemans
Senior Consultant
BMC, Belgium