Dear monks.Please help me with this code.This is my beginner's steps in writing perl and I am trying but in vain.The code does not proceed to the next line after getting the $opt2 = <STDIN>; in the main loop.please point out the mistake.I have not used strict but apart from that I cannot see any problem myself

#!/usr/local/bin/perl5 &main_loop; ########################################################## ## Details of this program: ## The program is divided into the following steps and can be underst +ood as follows: ## 1.The location of files are initialized to scalar variables for ea +sy location of the files themselves wherever needed ## 2.The subroutine init_vector is called with an argument(namely: pl +ant,train,place/person).It will for each of the given argument ## by the user store the weight as a "value"of an array of hash whe +re the key value is the "term"and the index is the serial no of the ## .I document i.e the document.Also the subroutine will be designe +d in such a way that by just changing the fixed weight value in the ## subroutine we can easily implement either of the two proposed we +ighing schemes of part 2. ## 3.The subroutine for calculation of centroids is defined. ## 4.Then there will be subroutines for calculation of full cosine si +milarity which will take the inputs from the two centroid vectors ## and return their similarity values,the differences in their valu +es and hence the sorted array.This is then printed out here ## itself. ## Also printed out in the end is the ratio of correct /total coun +ts. ## ## ## ## ########################################################## ########################################################## ## INIT_INPUT_FILENAMES, ## ## This function specifies the names and locations of ## input files used by the program. ## ## Parameter: $type ("stemmed" or "unstemmed") ## ## If $type == "stemmed", the filenames are initialized ## to the versions stemmed , while ## in the default ("unstemmed") case initializes to files ## containing raw, unstemmed tokens. ## ## ########################################################## sub init_input_filenames{ local($type) = @_; $DIR="."; if ($type eq "stemmed") { $plant ="$DIR/plant.stemmed"; $plant_hist ="$DIR/plant.stemmed.hist"; $plant_titles ="$DIR/plant.titles"; $tank ="$DIR/tank.stemmed"; $tank_hist ="$DIR/tank.stemmed.hist"; $tank_titles ="$DIR/tank.titles"; $perplace ="$DIR/perplace.stemmed"; $perplace_hist ="$DIR/perplace.stemmed.hist"; $perplace_titles ="$DIR/perplace.titles"; $common_words ="$DIR/common_words.stemmed"; } else { $plant ="$DIR/plant.tokenized"; $plant_hist ="$DIR/plant.tokenized.hist"; $plant_titles ="$DIR/plant.titles"; $tank ="$DIR/tank.tokenized"; $tank_hist ="$DIR/tank.tokenized.hist"; $tank_titles ="$DIR/tank.titles"; $perplace ="$DIR/perplace.tokenized"; $perplace_hist ="$DIR/perplace.tokenized.hist"; $perplace_titles ="$DIR/perplace.titles"; $common_words ="$DIR/common_words"; } } sub main_loop{ print "Please enter the choice for using the stemmed(1) or unstemm +ed documents(2)\n enter choice:"; $opt_st = <STDIN>; if ($opt_st !~/[12]/){$opt_st = 1;} chomp($opt_st); if($opt_st == 1){ &init_input_filenames("stemmed"); }else{ &init_input_filenames("tokenized"); } print "Please enter the choice for the parameter for which the sim +ilarity values would be calculated:plant(1),tank(2),person/place(3)\n + enter choice:\n opt1:"; $opt1 = <STDIN>; chomp($opt1); if ($opt1 !~/[123]/){$opt1 = 1;} print $opt1; print "Please enter a number for the options you want to have for +weighing : normal(1),eponential decay(2),stepped (3)\n"; print "enter choice for opt2:"; $opt2 = <STDIN>; print"I am a aperl monk"; chomp($opt2); if($opt2 !~ /[123]/){$opt2 = 1;} print $opt2;


In reply to Help with a perl code by varunreeves

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.