http://www.perlmonks.org?node_id=1017140


in reply to parsing help required

Just go over the lines. If you see a tool, remeber the relevant information. If you see the user, report the remembered information:
#!/usr/bin/perl use warnings; use strict; my $user = shift; my ($tool, $issued, $use); while (<DATA>) { if (my ($t, $i, $u) = /^Users of (.*?) ?\(total ([0-9]+) licenses +issued; total ([0-9]+) license/) { ($tool, $issued, $use) = ($t, $i, $u); } if (/^$user,(.*)/) { print "Using $tool since $1 (issued $issued, in use $use)\n"; } } __DATA__ Users of spice (total 20 licenses issued; total 0 license in use) Users of runner (total 10 licenses issued; total 0 license in use) Users of monitor(total 10 licenses issued; total 2 license in use) Alex,Mon 20 Jan 2013 Peter,Wed 26 Jan 2013 Users of report (total 15 licenses issued; total 0 license in use) Users of galaxy(total 10 licenses issued; total 3 license in use) Martin,Fri 22 Jan 2013 Alex,Mon 21 Jan 2013 Peter,Wed 24 Jan 2013
BTW, is the space after galaxy really missing? If no, you can remove the question marks from the regex.
لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ