FishingIwishIwas
Technical User
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
#!/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