On Sun, Feb 02, 2003 at 07:49:28AM -0500, Wizard wrote:
> For some reason you end up with an extra empty array entry (I'm not sure
> why).

No, you don't.

> Here's my test code:
> 
> $_='use_name,mat_id,use_id,use_fname,mat_name,use_lname';
> $_ =~ s/(([a-zA-Z0-9]+)_\w+)/push @{$group{"$2"}}, "$1"; $1/ge;
> print "$_\n";
> for( keys %group ) {
>     print "$_ = [", join "]\, [", @{$group{ $_ }}, "]\n";
> }

You need parens around join's arguments to let print see the final
"]\n".  The final "]\n" is your "extra array entry".

$_='use_name,mat_id,use_id,use_fname,mat_name,use_lname';
$_ =~ s/(([a-zA-Z0-9]+)_\w+)/push @{$group{"$2"}}, "$1"; $1/ge;
print "$_\n";
for( keys %group ) {
    print "$_ = [", join ("]\, [", @{$group{ $_ }}), "]\n";
}

(Parentheses are our friends.)

-- 
John Tobey <[EMAIL PROTECTED]>
\____^-^
/\  /\
_______________________________________________
Boston-pm mailing list
[EMAIL PROTECTED]
http://mail.pm.org/mailman/listinfo/boston-pm

Reply via email to