On Jun 7, Byron Rendar said:

>my $input    = <STDIN>;
>  my $username = chop( $input );
>print "$username";
>
>Why are double quotes around $username a "bad" thing in the print statement?

They enforce stringification.  This can be a problem when printing arrays,
or sending references to functions:

  @array = <FILE>;
  print @array;    # that looks ok
  print "@array";  # "why's there space in front of every line but the 1st?"

  $x = [ 1,3,5,7 ];
  foo($x);    # ok, prints 4
  foo("$x");  # d'oh!

  sub foo { print scalar @{ shift() } }

-- 
Jeff "japhy" Pinyan      [EMAIL PROTECTED]      http://www.pobox.com/~japhy/
I am Marillion, the wielder of Ringril, known as Hesinaur, the Winter-Sun.
Are you a Monk?  http://www.perlmonks.com/     http://forums.perlguru.com/
Perl Programmer at RiskMetrics Group, Inc.     http://www.riskmetrics.com/
Acacia Fraternity, Rensselaer Chapter.         Brother #734
**      Manning Publications, Co, is publishing my Perl Regex book      **

Reply via email to