Here is the latest version of my script:

#!/usr/bin/perl -w
use strict;

my $Pixarport = 7498;
my $host = "lex";
my $Pixarfile = $Pixarport."@".$host;
my @input;
my $line;
my $line_number;
my $file_length;
my @features_array;
my @handles_array;
my $handles;
my $features;
my $sizeof;
my $counter = 0;
my $answer;
my $string;
my $userid = `whoami`;

@input = `cat clicenses_output`;
$file_length = scalar(@input);

print "Is ".$userid." your userid (Y or N)?";
$answer = <STDIN>;
if ($answer =~ /^[nN]$/) {
    print "Enter your userid: ";
    chomp($userid = <STDIN>);
}elsif ($answer =~ /^[yY]$/) {
    print $userid." is your userid.\n";
} 

print "Do you wish to:"."\n";
print "1) remove all of your floating licenses at
once"."\n";
print "2) remove them one at a time"."\n";
$answer = <STDIN>;

if ($answer == 1) {
    foreach ($line_number = 0; $line_number <=
$file_length; $line_number++){
        last if ($line_number == $file_length);
        $line = $input[$line_number];
        next unless $line =~ /\S/;
        $line =~ s/^\s+//;
        @features_array = split /\s/, $line ;   
#split $line along whitespace and place into an array
        LOOKING_USERS: if ($features_array[0] eq
"Users") {
            ($features = $features_array[2]) =~ s/://;
   #assign second element into $features and remove
colon
            $line_number++;
        }
        $line = $input[$line_number];   
        if ($line =~ /Users/) {
                @features_array = split /\s/, $line;  
 #split $line along whitespace and place into an array
                goto LOOKING_USERS;
        }
        next unless $line =~ /\S/;
        $line =~ s/^\s+//;
        @handles_array = split /\s/, $line;    #split
$line along whitespace and place into an array
        $sizeof = scalar(@handles_array);
        if ($sizeof >= 9 && $handles_array[0] eq
$userid){
            ($handles = $handles_array[5]) =~ s/\),//;
   #assign ninth element into $handles and remove ),
            $string = join " ", @handles_array;
            print $string."\n";
            print "lmutil lmremove -c ".$Pixarfile."
-h ".$features." ".$host." ".$Pixarport."
".$handles."\n";
        }
    }
}

Basically, I'm trying to add some extra functionality
to the script.  I want the user to be able to pick
between have the script automatically remove all of
the licenses for them or query them like so:

Remove such-and-such license (Y or N)?

What would be the best way of going about this?

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to