in reply to Different behaviours in the similar scripts

The difference is in the parentheses:

my ($hostname) = split /\./, $NODE;

versus

$hostname = split /\./, $NODE;

The first statement, with the parentheses, means that the left-hand side is a list, and thus the right-hand side is evaluated in list context and the first element of the list gets assigned to $hostname.

The second statement, without the parentheses, means that the left-hand side is a scalar, and thus the right-hand side is evaluated in scalar context and returns the number of elements. That is the number you then see in $hostname.