#!/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"; }; }; #### choas@$ ./lal inpt User: test2user "Password": "Testpassword" "Framed-Protocol": PPP "Ascend-Idle-Limit": 600 User: testuser "User-Service": Framed-user "Authentication-Type": Unix-PW "Framed-Address": 222.222.222.222 "Framed-Protocol": PPP "Ascend-Metric": 3 "Ascend-Route-IP": Route-IP-Yes "Framed-Netmask": 255.255.255.255 "Ascend-Idle-Limit": 600