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

Re: [MacPerl] Novice question regards subroutines



At 22:58 -0400 9/20/98, Jon Lucenius wrote:
>#!perl -wl
>$x = "one plus one";          #watch out for this one!
>print "yes" if $x = "two";    #Why does this work? The assignment succeeded,
>print $x;                            #so it's true.
>
>
>This works because of the /"$x = "two"/ part.
>This is always true, because it assigns the value succesfully.
>Change the second line to /"$x = "five"/ and it still works.
>Note that /"$x eq "two"/ does not work ;(
>
>Jon

Now for extra credit, try

#!perl -wl

$x = "one plus one";
print "yes" if $x = "";
print "\$x is $x\n";

# Found = in conditional, should be ==.
File 'Untitled'; Line 4
$x is

What I was expecting was no "Yes", but also no warning.

   --John
--
John Baxter   jwblist@olympus.net      Port Ludlow, WA, USA
Give a man a fish and you feed him for a day.  Teach him to fish,
and you get rid of him for the weekend.

***** Want to unsubscribe from this list?
***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch