in reply to Can this code be optimized further?

This works w/o pcre's and more than a and b, though it stores in a hash.
#!/usr/bin/perl use warnings; use strict; my @temp = qw( a_1 b_1 a_2 a_3 a_4 b_2 a_5 b_3 a_6 b_4 ); my %parts; push @{ $parts{ substr $_, 0, 1 }}, substr $_, 2 foreach @temp; use Data::Dumper; print Dumper \%parts;

Replies are listed 'Best First'.
Re^2: Can this code be optimized further?
by Anonymous Monk on Feb 10, 2005 at 17:56 UTC
    This works w/o pcre's

    I assume that by "pcre" you mean Perl Compatible Regular Expressions. Now -- putting aside all questions of how compatible those regexes really are -- I'd like to mention that when we're using Perl, we don't have to call them "Perl Compatible". We just call them "Regular Expressions". ;-P

      Yep, but I often talk to people not involved, so it's just a habit. Besides, I find it more aesthetic than "re's" or "RegExp's" or something :)