Wolf Blaum wrote:
>
> For Quality purpouses, Anthony J Segelhorst 's mail on Monday 26 January 2004
> 17:17 may have been monitored or recorded as:
>
> > How come when I push a variable to an array it puts one whitespace before
> > the variables on all the lines except the first one? I would except all
> > the lines not to have the extra white space.
> ..
> > print "@temparray";
>
> Try print @temparay;
>
> since you have a "\n" at the end of your array (btw: do you really want
> that?) , your records are seperated by something when you print them.
> print " " puts a space in between the eleent as a convienience for people who
> dont have a "\n" at the end of their emelents.

The right conclusion for the wrong reasons Wolf! The spaces are the result of
interpolating the array into a string, and the presence of a newline on each
array element is immaterial:

  my @arr = ('A', 'B', 'C', 'D');
  print "@arr\n";
  print @arr, "\n";

**OUTPUT

  A B C D
  ABCD

In general, it's a bad idea to put variables inside double quotes unless know
what it means.

  my $var = $value

is much more likely to be right than

  my $var = "$value"

and the latter is very similar to adding zero to a numeric varibale.

Cheers,

Rob




-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to