in reply to printing referenced arrays weirdness

This is fun.

The reason your printing is sorta backwards is because you commented out the 'end of line' and you are concatenating the string from the 1st print statement with the second print statement.

In other words, your code (snippet) (when the comments are removed) looks like:

print "test_array: @$test_array " . print "test_array2: @$test_array2\ +n";
Sandy

Replies are listed 'Best First'.
Re: Re: printing referenced arrays weirdness
by davido (Cardinal) on Nov 27, 2003 at 04:44 UTC
    To be more specific, both prints are executing, but the first print executes second, since its entire parameter list must be evaluated before it can print. Part of its argument list is the second print function.

    So the 2nd print function executes first. Then the return value of the 2nd print (almost certanly '1') is concatenated to the output of the first print function.

    What a mess huh? lol. Don't worry about it, it's easy to fix, and almost nobody is (wo)man enough to use "cat" to write perfect Perl scripts first time around.


    Dave


    "If I had my life to live over again, I'd be a plumber." -- Albert Einstein