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

[MacPerl] In the continuing vein of substitution....



Try this:

#!/usr/local/bin/perl

    @a = <<END_NUMBERS;
0
1
2
3
4
5
6
7
8
9
10
END_NUMBERS

    print "Yes\n" if @a =~ /10/;
    print "No\n" if @a !~ /10/;

    undef @a;

    for( $i=0; $i<=10; $i++ ){
        $a[$i] = $i + 1;
        }

    print "Yes\n" if @a =~ /10/;
    print "No\n" if @a !~ /10/;
    exit( 0 );

The answers are "No" and "No";  However, Chris' example of:

	@a = 0..9;
	print "Yes\n" if @a =~ /10/;

Returns "Yes".  Go figure.  :-)

My input on the above is that the first example converts the numbers to
letters.  The second example though clearly does arithmetic (adding one
to the number) and therefore should be saved as a number (ie: 1-11).  So
it should be stored like Chris' example and should return "Yes" anyway. 
But it doesn't.  :-)

(Hey!  Is this counted as testing?  ;-) )

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