Click here to get back home

FAQ 5.39 Why do I get weird spaces when I print an array of lines?

 HomeNewsGroups | Search | About
 comp.lang.perl.misc    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
FAQ 5.39 Why do I get weird spaces when I print an array of lines? PerlFAQ Server 03-16-2008
Posted by Abigail on March 17, 2008, 4:58 am
Please log in for more thread options
_
Ben Bullock (benkasminbullock@gmail.com) wrote on VCCCXI September
?? On Sun, 16 Mar 2008 06:03:03 -0700, PerlFAQ Server wrote:
??
?? > 5.39: Why do I get weird spaces when I print an array of lines?
?? >
?? > Saying
?? >
?? > print "@lines\n";
?? >
?? > joins together the elements of @lines with a space between them.
??
?? I recently learnt from a post here by Ben Morrow that it joins together
?? the elements of @lines with a $" between them:
??
?? ben ~ 502 $ perl -e '$"="bu";@ba=("bo","be");print "@ba\n";'
?? bobube
??
?? Shouldn't this FAQ entry mention $"?


No, it's a FAQ, not a reference guide.

People who set $" generally aren't surprised at having "weird spaces".


Abigail
--
srand 123456;$-=rand$_--=>@[[$-,$_]=@[[$_,$-]for(reverse+1..(@[=split
//=>"IGrACVGQ\x02GJCWVhP\x02PL\x02jNMP"));print+(map@[),"\n"

Posted by brian d foy on March 18, 2008, 5:15 pm
Please log in for more thread options

> On Sun, 16 Mar 2008 06:03:03 -0700, PerlFAQ Server wrote:
>
> > 5.39: Why do I get weird spaces when I print an array of lines?
> >
> > Saying
> >
> > print "@lines\n";
> >
> > joins together the elements of @lines with a space between them.
>
> I recently learnt from a post here by Ben Morrow that it joins together
> the elements of @lines with a $" between them:
>
> ben ~ 502 $ perl -e '$"="bu";@ba=("bo","be");print "@ba\n";'
> bobube
>
> Shouldn't this FAQ entry mention $"?

The FAQ shouldn't mention $". The answer is not about how to change
what happens, but to recognize in the default case that interpolating
an array has behavior.

But, the answer could be better.

Similar ThreadsPosted
FAQ 6.0: Why do I get weird spaces when I print an array of lines? December 18, 2004, 6:03 am
FAQ 6.0: Why do I get weird spaces when I print an array of lines? January 1, 2005, 6:03 pm
FAQ 6.0 Why do I get weird spaces when I print an array of lines? February 25, 2005, 6:03 am
FAQ 5.38 Why do I get weird spaces when I print an array of lines? May 8, 2005, 5:03 am
FAQ 5.38 Why do I get weird spaces when I print an array of lines? July 23, 2005, 10:03 pm
FAQ 5.38 Why do I get weird spaces when I print an array of lines? October 9, 2005, 10:03 am
FAQ 5.38 Why do I get weird spaces when I print an array of lines? December 15, 2005, 5:03 pm
FAQ 5.38 Why do I get weird spaces when I print an array of lines? December 22, 2005, 11:03 am
FAQ 5.38 Why do I get weird spaces when I print an array of lines? February 15, 2006, 12:03 pm
FAQ 5.38 Why do I get weird spaces when I print an array of lines? May 4, 2006, 9:03 pm

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap