basic perl question

Discussion of programming on Linux, including shell scripting, perl, python, c/c++, mono, java. Whatever tickles your fancy.
Post Reply
omer
Lance Naik
Posts: 44
Joined: Fri Sep 05, 2003 10:22 pm

basic perl question

Post by omer »

Code: Select all

#!/usr/bin/perl -w

use strict;
use Switch;

my $path = "test.txt";
my $choice = 0;
menu();

print("PATH: $path");




sub menu {
	print("================================\n");
	print("|    Omer's NFA Simulation      |\n");
	print("--------------------------------|\n");
	print("| Press [1] to specify a file   |\n");
	print("| Press [2] to test a String    |\n");
	print("| Press [3] to View Symbol Table|\n");
	print("| Press [4] to Quit             |\n");
	print("================================\n");
	
	print("Enter your choice: ");
	$choice = <STDIN>;
	$choice = chomp($choice);
	print("choice: $choice");

	if($choice == "1") {
		print("You pressed 1\n");
		change_path();		
	}
		
	elsif($choice == "2") {
		print("You pressed 2");
	}

	elsif($choice == "3") {
		print("derp derp der");
	}
	
	elsif($choice == "4") {
		print("You chose: $choice");
	}
	else {
		print("you f*** moron");
	}
	
}


sub readFile {
	print("read file");		
	}


sub change_path {
	
	print("Enter Test Filename: ");
	$path = <STDIN>;
	chomp($path);
	print("p: $path");
	#print("choice: $choice");
	#print("heck: $_");
	
}
can someone tell me what im doing wrong here...why does $choice always equal 1?
omer
Lance Naik
Posts: 44
Joined: Fri Sep 05, 2003 10:22 pm

Post by omer »

im sorry,
a bit drunk rite now...figured it out
admin: you can take this post off, twas a stupid mistake
Post Reply