use strict; use warnings; @agents = $session->GetAllAgents(); $i=1; $inputfile = "Agents.txt"; open (INPUTF, '>', $inputfile) || die("FATAL ERROR: Cannot open output file.\n"); foreach $agent($i) { foreach $agent (@agents) { my $num = $i ++; print INPUTF "$num "; print INPUTF "Agent Name = ". $agent->Name() . "\n"; print "$num. "; print "Agent Name = " . $agent->Name() . "\n";# } } close(INPUTF); print '*' x 80 ; print "\n"; print " Select Agent to Export:"; chomp ($choice = ); open(inputfile) or die("FATAL ERROR: Cannot open input file.\n"); my @lines = ; $fVal = ""; $line = ""; foreach $line (@lines) { if ( ($fVal ne "" ) && ( lc $fVal eq lc $choice ) ) { if($line =~ /$choice/) { $Agtname = "$line"; print $Agtname; my @values = split('=', $Agtname); $value = @values; $val = $values[2]; #$val =~ s/^\s+|\s+$//g; #$fVal = substr $val, 15; #print $fVal; #$Agtname = $fVal; #print $Agtname; last; } } } close(inputfile);