#!/usr/bin/perl -w use strict; my $UserID="Unknown"; my %UserData; while (<>) { next unless (/\w/io); #Skip empty lines if (/^(\S+)\s+(\S+)\s*=\s*(\S+)/io) # Match = to $1,$2,$3 { $UserID=$1; #Set $UserID to current user $UserData{$UserID}{$2}=$3; #Assign the data to the user in a hash next; #Next line, this was a special case }; s/\s+|\,//iog; #Remove spaces, and comma's (God forgive me for that one) my ($Key,$Val)=split /=/; #Get the Key, and Data $UserData{$UserID}{$Key}=$Val; #Assign it to the current user }; #Just some printing of the data. foreach my $User (keys %UserData) { print "User: $User\n"; foreach my $Data (keys %{$UserData{$User}}) { print "\t\"$Data\":\t$UserData{$User}{$Data}\n"; }; };