in reply to Help with a perl code

On my computer, if I enter 1 for $opt2, I get the print out I am aperl monk1. The "1" at the end comes from print $opt2.

Maybe you forgot to put in a new line after "I am a Perl Monk" and so couldn't see that you were in fact printing out $opt2 ? The Perl print command does not automatically add a new line at the end of a line. If you wish to add a new line every time you print you can set the perl variable $\ to "\n". See perlvar for more information.

Best, beth

update pointed out the "1" being contributed by print $opt2.

Replies are listed 'Best First'.
Re^2: Help with a perl code
by varunreeves (Initiate) on May 03, 2009 at 13:14 UTC
    Do u get the print for the line ----- print $opt2; ?? that is the last line in the code