in reply to reg ex. problem - 2 variables

The problem you are asking about:
You don't chomp the input from <STDIN>. So your $userinput contains a newline on the end. So your regex looks for the pattern only if it's followed by \n.

Other than that:
You will run into problems when running without use strict, which makes me guess you are not using use warnings.

Don't comment code self-explanatory code.
Ex.

open (REPORT, ">>$REPORTNAME") or die ("Cannot open"); # Open the rep +ort file for writing
Comments are for other programmers. If someone working on this program can't figure out you're opening a file, then there is a problem.


grep
One dead unjugged rabbit fish later

Replies are listed 'Best First'.
Re^2: reg ex. problem - 2 variables
by GrandFather (Saint) on Oct 04, 2006 at 20:30 UTC

    I'd add "Don't comment code so far over in the eastern hemisphere that you need magic or jet travel to get there." All those comments are on the ends of lines and padded so far to the right that on most monitors they would never be seen.

    I'd amplify your "Don't comment code self-explanatory code." comment: if you need to comment every line then the code you are writing is too tricky! Remember, it's at least twice as hard to debug something as it is to write it, so if you are writing the cleverest code you can, you can't debug it!


    DWIM is Perl's answer to Gödel
      so far to the right that on most monitors they would never be seen
      this might make a good poll. who keeps their terminals at 80 columns these days, and/or codes in an editor that doesn't have soft-wrapping?
Re^2: reg ex. problem - 2 variables
by praevalesco (Initiate) on Oct 04, 2006 at 20:09 UTC
    Perfect... who would have thought I'd overlook that. I really appreciate the help. -Nick