in reply to Re: regex to split a line
in thread regex to split a line

This looks to me like a good opportunity to use a hash slice.

use strict; use warnings; my %user_info; my @fields = qw(name email foo bar); while (<DATA>) { chomp; my ($user, $attribs) = split /\s+/, $_, 2; my %record; @record{@fields} = split /\|/, $attribs; $user_info{$user} = \%record; } foreach my $user (keys %user_info) { print "Username:$user Real Name:$user_info{$user}{name}\n"; }
--
<http://dave.org.uk>

"The first rule of Perl club is you do not talk about Perl club."
-- Chip Salzenberg