[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] Please don't Laugh at me... PAULINE Hola amigo



Jorge,
What is wrong?
(1) There are no MACPerl-specific problems; therefore, you might better have
send this to the MacPerl-AnyPerl@macperl.org mailing list. [Well, (4) is
a MacPerl-specific construct.]
(2) Please RTFM -- MacPerl Power and Ease by Chris and Vicki is your best bet
for MacPerl, not to mention the OnLine documentation (perlrun.html, ...).
(3) There are no comments (they start with a pound sign (#) on an empty line
or after the semi-colon which ends a statement).
(4) (Almost) *ALWAYS* start your MacPerl program with the line "#!perl -w".
The "-w" enables more extensive debugging, the #!perl convinces MacPerl
that it is really executing a Perl script.
(5) "=" is used for ASSIGNMENT, i.e. putting a copy of a right-hand-value into
a left-hand-value (like a $variable, $array[index], or $hash{"key"})).
(6) "==" is used for NUMERIC EQUALITY.  Comparing integer or floating-point
numbers.   Use "eq" for exact alphanumeric equality.
(7) In your program, since you haven't removed any line termination, "eq"
would always fail, so you are much better off matching "pauline" (anycase)
anywhere in the input line << $input =~ /pauline/i  >>.
(8) naked values like PAULINE are depreciated, always surround with single
or double quotes, or use in a match or substitute expression.


Code that probably does what you want:
#!perl -w
#                             pauline_hola.pl
###############################################################
#
#  No arguments.
#  If "pauline" is typed anywhere in the input line,
#  "Hola amigo" is output, otherwise "I don't know you" is output.
#  "pauline" may be in any case.

#
# prompt for and get one line of input text
#
print ('Please type your name: ');
$input = <STDIN>;

#
# Check for "pauline"
#

if ($input  =~ /pauline/i){
  print ("Hola amigo\n");
}else{
  print("I don't know you\n");
}


>I am relatively new to MacPerl and I would like to know what is wrong
>with my code.
>
>print ('Please type something: ');
>$input = <STDIN>;
>if ($input = PAULINE){
>print ("Hola amigo\n")
>}else{
>print("I don't know you\n")
>}
>
>I want it to print out hola amigo if the STDIN is Pauline.  If not I want
>it to print out I don't know you.  Sorry to bother you guys...
>
>Jorge
>
>
>===== Want to unsubscribe from this list?
>===== Send mail with body "unsubscribe" to macperl-request@macperl.org

--
Regards, Larry F. Allen-Tonar        (larryat@cts.com) +1 760/746-6464 (voice)
         Principal Designer                              +1 760/746-0766 (FAX,
         P.O. Box 463072                                         upon request)
         Escondido, CA  92046-3072



===== Want to unsubscribe from this list?
===== Send mail with body "unsubscribe" to macperl-request@macperl.org