in reply to Re^2: Why am I getting Can't use string (<string value>) as an ARRAY ref wile "strict refs" in use
in thread Why am I getting Can't use string (<string value>) as an ARRAY ref wile "strict refs" in use
Pretty printing is left as an exercise:
OUTPUT:#!/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)
$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.
|
|---|