snafu has asked for the wisdom of the Perl Monks concerning the following question:

perl -e '$var="11/22";$x,$y = split("/",$var,);print "x is $x and y is + $y\n";' x is and y is 2 perl -e '$var="11/22";$x,$y = split(/\//,$var,);print "x is $x and y i +s $y\n";' x is and y is 2

What am I doing wrong here?

----------
- Jim

Replies are listed 'Best First'.
(jeffa) Re: split() not working the way I would expect...
by jeffa (Bishop) on Aug 25, 2001 at 00:21 UTC
    You forgot to specify a LIST on the left hand side:
    perl -e '$var="11/22";($x,$y) = split("/",$var,);print "x is $x and y +is $y\n";'

    jeffa

        A flute with no holes is not a flute . . .
    a doughnut with no holes is a danish.
                                    - Basho,
                                      famous philosopher
    
Re: split() not working the way I would expect...
by blakem (Monsignor) on Aug 25, 2001 at 00:22 UTC
    perl -e '$var="11/22";($x,$y) = split(/\//,$var,);print "x is $x and y + is $y\n";'
    Update: darn, just a little slow on the draw....
    Update2: but not quite as slow as the AM below... looks like it took nearly 12 hours to type that one up. ;-)

    -Blake

Re: split() not working the way I would expect...
by Anonymous Monk on Aug 25, 2001 at 12:03 UTC
    perl -e '$var="11/22";($x,$y) = split("/",$var);print "x is $x and y i +s $y\n";'