Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Why am I getting extra space in front of line 2 and 3?

Status
Not open for further replies.

FishingIwishIwas

Technical User
Jun 16, 2006
5
US
Don't know why I get an extra space in front of line 2 and 3 when I use and array:

#!/usr/local/bin/perl -w
my @buf;
my $str1 = "line 1\n";
my $str2 = "line 2\n";
my $str3 = "line 3\n";
push @buf, $str1;
push @buf, $str2;
push @buf, $str3;
print "The content of buffer is:\n";
print "@buf";
print "versus print directly:\n";
print "$str1$str2$str3";

The output looks like this:

The content of buffer is:
line 1
line 2
line 3
versus print directly:
line 1
line 2
line 3


 
When the array @buf is extrapolated in the string, spaces are inserted.

print @buf;

is what you're after
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top