develooper Front page | perl.beginners | Postings from February 2002

Help with simple menus

Thread Next
From:
Tim Lago
Date:
February 27, 2002 12:02
Subject:
Help with simple menus
Message ID:
20020227200154.36961.qmail@onion.perl.org
I have this perl script that works for what I need to do with it except for
the menus.  I am new to perl and I have found out that I can download menu
modules that can do what I want, but I am looking for a simpler solution.

Ok, the question I have is this, can I create a simple menu that allows for
the user to select from a pre defined section of choices, 1-5, and how would
I do this.  What I have done with the first two choices doesn't work, it
always defaults to the first choice.

Anyway help would be greatly appreciated it.


#!/perl/bin

#This allows the user to choose the Access log of the Real Media Server

print "Enter the name of the Real Media Access Log:\n";
print "\n";

chomp($infile = <STDIN>);

open(INFILE, "$infile") or die "Can't open the Real LOG!: $!";
open(OUTFILE, ">outfile.1") or die "Can't create outfile.txt: $!";

print "Enter name of the Real Media file; \n";
print "\n";

chomp($realname = <STDIN>);

$counter = 0;

while(<INFILE>) {
 if(/$realname/) {
 print OUTFILE;
 $counter++;
 }
}

print "$counter matches \n";

print "\n";

# This section allows the user to choose the type of connection that was
made to the Real Media File

print "Choose the type of connection:\n\n";

print "1- Proxy Server: Site 1, 10.1.1.234 \n\n";

print "2- Proxy Server: Site 2, 10.1.2.234 \n\n";

print "3- Proxy Server: Site 3, 10.1.3.234 \n\n";

print "4- Proxy Server: Site 4, 10.1.3.234 \n\n";

print "5- All Proxy Servers \n\n";

print "6- All Non Proxy Connections \n\n";

chomp($choice = <STDIN>);

open(INFILE, "outfile.1") or die "Can't open input file!: $!";
open(OUTFILE, ">outfile.2") or die "Can't create out put file!: $!";

$count = 0;


if ($choice = 1){
  while(<INFILE>){
  if(/10.1.1.234/){
  print OUTFILE;
  $count++;
  }
 }
}

elsif ($choice = 2){
  while(<INFILE>){
  if(/10.1.2.234/) {
  print OUTFILE;
  $count++;
  }
 }
}

print "$realname was accessed on choice $choice, $count times. \n";





Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About