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

Hai all,
I am new to PERL.I have a problem in concatenation of two strings in a program.
The problem is as follows
I have a value $OID = 1.2.3.6.9.5.6.8
I have another value = 5
now i want to concatenate these two values so the output is like this 1.2.3.6.9.5.6.8.5
i already used the "." for concatenation .But while printing that value it is giving the output 1.2.3.6.9.5.6.8 in one line and .5 in other line
But i want the entire output(i.e.. 1.2.3.6.9.5.6.8.5) in one variable.could anybody please solve my problem

Thanks
Satya

Replies are listed 'Best First'.
Re: concatenation in perl
by moritz (Cardinal) on Feb 27, 2008 at 09:46 UTC
    It seems that $OID contains a trailing newline, so you have to remove that before concatenating the strings:
    chomp $OID; my $new_OID = $OID . '.5'; print $new_OID, "\n";
Re: concatenation in perl
by marto (Cardinal) on Feb 27, 2008 at 09:55 UTC
Re: concatenation in perl
by ikegami (Patriarch) on Feb 27, 2008 at 10:33 UTC

    Are you sure you did
    my $OID = "1.2.3.6.9.5.6.8"
    and not
    my $OID = "1.2.3.6.9.5.6.8\n"?

    If you did my $OID = <SOME_HANDLE>;, you did the latter. To remove the trailing newline, use chomp: chomp( my $OID = <SOME_HANDLE> );