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


in reply to help need with flexlm

so... what have you tried? Are you concerned about total number of licenses of all products or each product? Either way it is a fairly straight forward detection of what lines you are on

if ( $line =~ m@Users of Product@ ) { $line =~ m@Product(\d+):@; # match and capture product number $product = $1l
and tallying the user's product usage
$line = s/\s+//; #get rid of the leading spaces my @f=split(/[\s\t]+/,$line); my $user=$f[0]; # if our hash does not contain an entry for our user $counter{$user} = [] if ( ! defined($counter{$user}) ) ; $counter{$user}->{$product}++;
Once you have your counts I'm sure you can work out how to calculate percentages. As far as making your script send email there are plenty of articles on that on PM (try a super search) and my own blog has examples of how to do that (offsite link) here.


Peter L. Berghold -- Unix Professional
Peter -at- Berghold -dot- Net; AOL IM redcowdawg Yahoo IM: blue_cowdawg

Replies are listed 'Best First'.
Re^2: help need with flexlm
by vkknava (Novice) on May 04, 2013 at 13:16 UTC
    I need for each product. If a user uses 30% of the total number of a product, I need an email. I will try with what you have suggested and let you know with the result.

      I tried with the first half of the code. But it is not printing the number.

      Another thing is I have many products in the output file. I am calculating the usage of each product.

      #!/usr/bin/perl local $/; open(DAT, "output1.txt") || die("Could not open file!"); my $line = <DAT>; my $product; if ( $line =~ m/Users of/ ) { $line =~ m@Product(\d+):@; $product = $1; print $product; }