in reply to Perl Context - concatenation operator

You are doing a vstring assignment here. The . characters are not concatenating your digits together like you thought.

$a = 1.2.3; print $a; #printing junk characters

If you were using strings then it would do it but not numbers. This is what you were thinking would happen.

$a = "1"."2"."3"; print $a;

A better example for working with a normal number would be this,

$a = 1.20; print $a;

1.20 is a proper number, would you expect it to be '1.20' or 120? Vstrings are a little different however.

Replies are listed 'Best First'.
Re^2: Perl Context - concatenation operator
by ikegami (Patriarch) on Dec 21, 2006 at 15:15 UTC

    $a = "1"."2"."3";

    Just putting spaces is sufficient.
    >perl -e "print 1.2.3
    ☺☻♥
    >perl -e "print 1 . 2 . 3
    123