in reply to struggling with sub-routines

As arturo said in his earlier reply, to return a list of values from a subroutine you need to use:
return ($first, $second, $third, $fourth, $others);
To retrive this list from your subroutine you need to use the following:
@ret = catergory();
I have omitted the $first that you were sending to the subroutine as I believe you meant to send @array (which was obtained from the file) instead although I'm not sure of this.

There are some other possible problems with your code but I'm still having trouble understanding what your trying to do. If you explain in more depth your aims this would greatly help.

Good luck with your project!

~~rob
____________________________________________________________
eval pack "h*", "072796e647022245d445f475454494c5e622b3";

Replies are listed 'Best First'.
Re: Re: struggling with sub-routines
by Anonymous Monk on Jun 19, 2002 at 13:17 UTC
    The aims of this program are to catergorise the input file with regular expressions, then the user can select from the menu which catergory to look at ; eg
    1. choice1 2. choice2
    etc. i want the program to go back to the main menu after a choice has been made and the results are displayed.
      To loop the menu i would suggest using the following:
      while(1) { print "\nPlease select the catergory of results that you wish to s +ee;\n\n\t1. first \n\t2. second \n\t3. third \n\t4. forth \n\t5. Othe +rs etc\n\t6. Exit program\n\n"; chomp($choice = <STDIN>); if ($choice eq '6') { last; } #your code here }
      As for the rest of the program I am still unsure as to what the files your are parsing will be like. Could you give an example file?

      ~~rob
      ____________________________________________________________
      eval pack "h*", "072796e647022245d445f475454494c5e622b3";

        An example of the file is something like this:
        1269 /:tremblnew|AAL98468|AAL98468 344 873 6e-94 534 76 +7 166/177 93% 172/177 96% 767 533 3 590 766 1269 /:sptrembl|Q9F445|Q9F445 331 840 5e-90 534 72 +2 162/177 91% 169/177 94% 722 533 3 545 721 1269 /:tremblnew|AAK99986|AAK99986 143 357 2e-33 534 21 +3 72/165 43% 108/165 64% 213 533 39 46 209
        where the reg ex's would be something like;
        if (defined(($array[1] =~ m{/:sptrembl\|\w+\|\w+}) || ($array[1] =~ m{ +/:tre mblnew\|\w+\|\w+})) && ($array[8] > 95))
        thanks, i appreciate your help!