Ooooohkay, quick and dirty, how I would start: no error checking,
and clumsy, but maybe an Idea:
#!/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 <NewUser> <Tag>=<Data> 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 ca +se }; 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"; }; };
With your example data this gives me:
choas@<Censored to protect myself from my employer>$ ./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

Hope I gave you an Idea

GrtZ!

p.s. yeah, most of my quick 'n dirty progs are called 'lal' ;))

In reply to Re: strict by ChOas
in thread strict by toadi

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.