Here is some working code.

Pretty printing is left as an exercise:

#!/usr/bin/perl use strict; use warnings; use Data::Dumper; my %lic_info; my $pending_product=""; my $pending_user_count=0; my %actions=( "Flexible License Manager" => sub{ @lic_info{qw|DAY DATE TIME|} = $_[0]=~/ on (\w+) (\S+) (\S+)$ +/; }, "Users of " => sub{ my ($product,$issued, $usecount) = $_[0]=~/Users of (\w+): \( +Total of (\d+) license\w? issued; Total of (\d+) lic/; $lic_info{$product}{ISSUED}= $issued; $pending_user_count = $lic_info{$product}{USED}= $usecount; $pending_product = $product; }, ); my $regex = "(" . join ("|", keys %actions) . ")"; while (<DATA>){ if ( m/$regex/ ){ $actions{$1}->($_); # Where the work happens }elsif ($pending_product){ next if m/^\s+$/; next if m/floating license/; next if m/\s*\S?$pending_product/; push @{$lic_info{$pending_product}{USERS}}, m/(\S+)/; --$pending_user_count or $pending_product = ""; } } print Dumper \%lic_info; __DATA__ lmutil - Copyright (c) 1989-2009 Flexera Software, Inc. All Rights Res +erved. Flexible License Manager status on Wed 1/2/2019 07:00 [Detecting lmgrd processes...] License server status: 27000@unodecx80 License file(s) on unodecx80: E:\Program Files (x86)\IBM\RationalR +LKS\common\rational_server_perm.dat:E:\Program Files (x86)\IBM\Ration +alRLKS\common\rational_server_temp.dat: unodecx80: license server UP (MASTER) v11.10 Vendor daemon status (on unodecx80): ibmratl: UP v11.10 Feature usage info: Users of ClearCase: (Total of 10 licenses issued; Total of 1 license + in use) "ClearCase" v1.00000, vendor: rational floating license amlove unodecx86 WI_zfTVVG-n7Ph2jhkOo #u#amlove#u# (v1.0) (unodecx +80/27000 615), start Wed 1/2 6:56 (linger: 1800) Users of ADALangPack: (Total of 1 license issued; Total of 0 license +s in use)
OUTPUT:
$VAR1 = { 'ClearCase' => { 'USED' => '1', 'USERS' => [ 'amlove' ], 'ISSUED' => '10' }, 'ADALangPack' => { 'ISSUED' => '1', 'USED' => '0' }, 'DATE' => '1/2/2019', 'DAY' => 'Wed', 'TIME' => '07:00' };

Update: FYI/FWIW - I was a ClearCase admin in a previous job, decades ago, and I sympathize. That was what taught me perl - so good luck !

                As a computer, I find your faith in technology amusing.


In reply to Re^3: Why am I getting Can't use string (<string value>) as an ARRAY ref wile "strict refs" in use by NetWallah
in thread Why am I getting Can't use string (<string value>) as an ARRAY ref wile "strict refs" in use by 5NOMAD7

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.