in reply to regexp parsing from a big string...
use Data::Dumper; for my $record (split m/\n\n\n/, $tempStr){ my %user_info; for (split m/\n/, $record){ if (m/^User (.*)$/){ $user_info{name} = $1; } elsif (m/^(\w+)\s*=\s*(.*)$/){ $user_info{$1} = $2; } } print Dumper \%user_info if %user_info; }
(Update: Code now actually works).
Note that your email addresses a@b.com try to interpolate the array @b if the string is in double quotes, so please use single quotes (or even better, a here-doc) instead.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: regexp parsing from a big string...
by kyle (Abbot) on May 12, 2008 at 20:33 UTC |