<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
		>
<channel>
	<title>Comments on: Explantion on the use of chop() and chomp() functions.</title>
	<atom:link href="http://thejoysofcomputing.wordpress.com/2009/08/31/explantion-on-the-use-of-chop-and-chomp-functions/feed/" rel="self" type="application/rss+xml" />
	<link>http://thejoysofcomputing.wordpress.com/2009/08/31/explantion-on-the-use-of-chop-and-chomp-functions/</link>
	<description>Used to be something else but now basically contains some useful PHP scripts. That&#039;s all!</description>
	<lastBuildDate>Tue, 18 Oct 2011 23:30:29 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
	<item>
		<title>By: crz</title>
		<link>http://thejoysofcomputing.wordpress.com/2009/08/31/explantion-on-the-use-of-chop-and-chomp-functions/#comment-27</link>
		<dc:creator><![CDATA[crz]]></dc:creator>
		<pubDate>Thu, 03 Sep 2009 04:56:48 +0000</pubDate>
		<guid isPermaLink="false">http://thejoysofcomputing.wordpress.com/?p=54#comment-27</guid>
		<description><![CDATA[Thanks Chas for pointing out. i made some revisions. I believe now the explanation is correct. But please check, if there is still corrections to be done, I&#039;ll.]]></description>
		<content:encoded><![CDATA[<p>Thanks Chas for pointing out. i made some revisions. I believe now the explanation is correct. But please check, if there is still corrections to be done, I&#8217;ll.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chas. Owens</title>
		<link>http://thejoysofcomputing.wordpress.com/2009/08/31/explantion-on-the-use-of-chop-and-chomp-functions/#comment-26</link>
		<dc:creator><![CDATA[Chas. Owens]]></dc:creator>
		<pubDate>Thu, 03 Sep 2009 04:38:58 +0000</pubDate>
		<guid isPermaLink="false">http://thejoysofcomputing.wordpress.com/?p=54#comment-26</guid>
		<description><![CDATA[My point is that you are claiming that the readline operator is adding a newline to the string, and that claim is wrong.  The newline is already there.]]></description>
		<content:encoded><![CDATA[<p>My point is that you are claiming that the readline operator is adding a newline to the string, and that claim is wrong.  The newline is already there.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: crz</title>
		<link>http://thejoysofcomputing.wordpress.com/2009/08/31/explantion-on-the-use-of-chop-and-chomp-functions/#comment-24</link>
		<dc:creator><![CDATA[crz]]></dc:creator>
		<pubDate>Thu, 03 Sep 2009 03:57:45 +0000</pubDate>
		<guid isPermaLink="false">http://thejoysofcomputing.wordpress.com/?p=54#comment-24</guid>
		<description><![CDATA[yes, you are right. chomp() removes what is declared in &#039;$/&#039; while chop() removes the last character.]]></description>
		<content:encoded><![CDATA[<p>yes, you are right. chomp() removes what is declared in &#8216;$/&#8217; while chop() removes the last character.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: crz</title>
		<link>http://thejoysofcomputing.wordpress.com/2009/08/31/explantion-on-the-use-of-chop-and-chomp-functions/#comment-23</link>
		<dc:creator><![CDATA[crz]]></dc:creator>
		<pubDate>Thu, 03 Sep 2009 03:56:24 +0000</pubDate>
		<guid isPermaLink="false">http://thejoysofcomputing.wordpress.com/?p=54#comment-23</guid>
		<description><![CDATA[exactly, that is what I said when I said If we explicitly assign ‘f’ to ‘$/’ the line will end where it first sees a n ‘f’.]]></description>
		<content:encoded><![CDATA[<p>exactly, that is what I said when I said If we explicitly assign ‘f’ to ‘$/’ the line will end where it first sees a n ‘f’.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andrew</title>
		<link>http://thejoysofcomputing.wordpress.com/2009/08/31/explantion-on-the-use-of-chop-and-chomp-functions/#comment-21</link>
		<dc:creator><![CDATA[Andrew]]></dc:creator>
		<pubDate>Thu, 03 Sep 2009 03:20:33 +0000</pubDate>
		<guid isPermaLink="false">http://thejoysofcomputing.wordpress.com/?p=54#comment-21</guid>
		<description><![CDATA[Chop isn&#039;t really &quot;better&quot;. If you&#039;re using &lt;&gt; you should always be using chomp with it, because they both use $/ in the same way. &lt;&gt; reads everything up to and including the record separator, and chomp removes the record separator. If you use chomp, your code will do the right thing whether $/ is &quot;\n&quot; or &quot;\r\n&quot; or &quot;\n--\n&quot; or \4096. If you use chop, it won&#039;t always work.]]></description>
		<content:encoded><![CDATA[<p>Chop isn&#8217;t really &#8220;better&#8221;. If you&#8217;re using &lt;&gt; you should always be using chomp with it, because they both use $/ in the same way. &lt;&gt; reads everything up to and including the record separator, and chomp removes the record separator. If you use chomp, your code will do the right thing whether $/ is &#8220;\n&#8221; or &#8220;\r\n&#8221; or &#8220;\n&#8211;\n&#8221; or \4096. If you use chop, it won&#8217;t always work.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chas. Owens</title>
		<link>http://thejoysofcomputing.wordpress.com/2009/08/31/explantion-on-the-use-of-chop-and-chomp-functions/#comment-18</link>
		<dc:creator><![CDATA[Chas. Owens]]></dc:creator>
		<pubDate>Wed, 02 Sep 2009 19:53:18 +0000</pubDate>
		<guid isPermaLink="false">http://thejoysofcomputing.wordpress.com/?p=54#comment-18</guid>
		<description><![CDATA[Drat the lack of a preview option.  All of my angle brackets were interpreted as HTML.  Here it is again with entities instead:



The input record separator ($/) does in fact contain “\n” by default. That is why the readline operator (&lt;&gt;) returns lines, but the readline operator does not add “\n” to lines. That character is already part of the line in the file you are reading from. STDIN is no different from any other file. Pressing enter is not some magic thing that cause Perl to read the line. Pressing enter generates a newline. Perl sees the newline (just like it sees every character), compares it to what is currently set in $/, sees that they are the same, so it returns the string including the “\n” that you — not the readline operator — put there.

If you were to set the input record separator to “\n===\n” then it would return a multi-line string that ends with “\n===\n” (or the entire file if it doesn’t contain “\n===\n”). Try this on the commandline:

perl -e ‘$/ = “\n===\n”; my $record = &lt;STDIN&gt;; print “I saw: $record”‘

Type as much as you want, hit enter as many times as you want. Then (after hitting enter) type === and hit enter. The program will print back what you typed.]]></description>
		<content:encoded><![CDATA[<p>Drat the lack of a preview option.  All of my angle brackets were interpreted as HTML.  Here it is again with entities instead:</p>
<p>The input record separator ($/) does in fact contain “\n” by default. That is why the readline operator (&lt;&gt;) returns lines, but the readline operator does not add “\n” to lines. That character is already part of the line in the file you are reading from. STDIN is no different from any other file. Pressing enter is not some magic thing that cause Perl to read the line. Pressing enter generates a newline. Perl sees the newline (just like it sees every character), compares it to what is currently set in $/, sees that they are the same, so it returns the string including the “\n” that you — not the readline operator — put there.</p>
<p>If you were to set the input record separator to “\n===\n” then it would return a multi-line string that ends with “\n===\n” (or the entire file if it doesn’t contain “\n===\n”). Try this on the commandline:</p>
<p>perl -e ‘$/ = “\n===\n”; my $record = &lt;STDIN&gt;; print “I saw: $record”‘</p>
<p>Type as much as you want, hit enter as many times as you want. Then (after hitting enter) type === and hit enter. The program will print back what you typed.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chas. Owens</title>
		<link>http://thejoysofcomputing.wordpress.com/2009/08/31/explantion-on-the-use-of-chop-and-chomp-functions/#comment-17</link>
		<dc:creator><![CDATA[Chas. Owens]]></dc:creator>
		<pubDate>Wed, 02 Sep 2009 19:50:48 +0000</pubDate>
		<guid isPermaLink="false">http://thejoysofcomputing.wordpress.com/?p=54#comment-17</guid>
		<description><![CDATA[The input record separator ($/) does in fact contain &quot;\n&quot; by default.  That is why the readline operator () returns lines, but the readline operator does not add &quot;\n&quot; to lines.  That character is already part of the line in the file you are reading from.  STDIN is no different from any other file.  Press enter is not some magic thing that cause Perl to read the line.  Pressing enter generates a newline.  Perl sees the newline (just like it sees every character), compares it to what is currently set in $/, sees that they are the same, so it returns the string including the &quot;\n&quot; that you -- not the readline operator -- put there. 

If you were to set the input record separator to &quot;\n===\n&quot; then it would return a multi-line string that ends with &quot;\n===\n&quot; (or the entire file if it doesn&#039;t contain &quot;\n===\n&quot;).  Try this on the commandline:

perl -e &#039;$/ = &quot;\n===\n&quot;; my $record = ; print &quot;I saw: $record&quot;&#039;

Type as much as you want, hit enter as many times as you want.  Then (after hitting enter) type === and hit enter.  The program will print back what you typed.]]></description>
		<content:encoded><![CDATA[<p>The input record separator ($/) does in fact contain &#8220;\n&#8221; by default.  That is why the readline operator () returns lines, but the readline operator does not add &#8220;\n&#8221; to lines.  That character is already part of the line in the file you are reading from.  STDIN is no different from any other file.  Press enter is not some magic thing that cause Perl to read the line.  Pressing enter generates a newline.  Perl sees the newline (just like it sees every character), compares it to what is currently set in $/, sees that they are the same, so it returns the string including the &#8220;\n&#8221; that you &#8212; not the readline operator &#8212; put there. </p>
<p>If you were to set the input record separator to &#8220;\n===\n&#8221; then it would return a multi-line string that ends with &#8220;\n===\n&#8221; (or the entire file if it doesn&#8217;t contain &#8220;\n===\n&#8221;).  Try this on the commandline:</p>
<p>perl -e &#8216;$/ = &#8220;\n===\n&#8221;; my $record = ; print &#8220;I saw: $record&#8221;&#8216;</p>
<p>Type as much as you want, hit enter as many times as you want.  Then (after hitting enter) type === and hit enter.  The program will print back what you typed.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: crz</title>
		<link>http://thejoysofcomputing.wordpress.com/2009/08/31/explantion-on-the-use-of-chop-and-chomp-functions/#comment-16</link>
		<dc:creator><![CDATA[crz]]></dc:creator>
		<pubDate>Wed, 02 Sep 2009 18:41:54 +0000</pubDate>
		<guid isPermaLink="false">http://thejoysofcomputing.wordpress.com/?p=54#comment-16</guid>
		<description><![CDATA[I&#039;m not completely aware of what you have said as I&#039;m still learning. Anyway I assume &lt;STDIN&gt; confirms that you have entered the input once you have enter the return key.
However I ran the below code and it is outputting a new line so what I said should be correct
&lt;code&gt;#!/usr/bin/perl
print $/;&lt;/code&gt;
But I&#039;ll read the documentation  and look into it deeper and change the post if there is anything wrong.
Anyway thanks for dropping in.]]></description>
		<content:encoded><![CDATA[<p>I&#8217;m not completely aware of what you have said as I&#8217;m still learning. Anyway I assume &lt;STDIN&gt; confirms that you have entered the input once you have enter the return key.<br />
However I ran the below code and it is outputting a new line so what I said should be correct<br />
<code>#!/usr/bin/perl<br />
print $/;</code><br />
But I&#8217;ll read the documentation  and look into it deeper and change the post if there is anything wrong.<br />
Anyway thanks for dropping in.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chas. Owens</title>
		<link>http://thejoysofcomputing.wordpress.com/2009/08/31/explantion-on-the-use-of-chop-and-chomp-functions/#comment-15</link>
		<dc:creator><![CDATA[Chas. Owens]]></dc:creator>
		<pubDate>Wed, 02 Sep 2009 14:56:13 +0000</pubDate>
		<guid isPermaLink="false">http://thejoysofcomputing.wordpress.com/?p=54#comment-15</guid>
		<description><![CDATA[It is import to note that &lt;STDIN&gt; is not adding the newlines, it is not stripping them.  They are already in the file being read (in this case they are put there by your hitting the enter key).  You can see the behavior clearly in this sample code:

perl -e &#039;print &quot;foo\nbar\nbaz&quot;&#039; &#124; perl -ne &#039;s/\n/CR/;print &quot;[$_]\n&quot;&#039;

The last line does not have a newline character, and it does not show up in the output.]]></description>
		<content:encoded><![CDATA[<p>It is import to note that &lt;STDIN&gt; is not adding the newlines, it is not stripping them.  They are already in the file being read (in this case they are put there by your hitting the enter key).  You can see the behavior clearly in this sample code:</p>
<p>perl -e &#8216;print &#8220;foo\nbar\nbaz&#8221;&#8216; | perl -ne &#8216;s/\n/CR/;print &#8220;[$_]\n&#8221;&#8216;</p>
<p>The last line does not have a newline character, and it does not show up in the output.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: crz</title>
		<link>http://thejoysofcomputing.wordpress.com/2009/08/31/explantion-on-the-use-of-chop-and-chomp-functions/#comment-14</link>
		<dc:creator><![CDATA[crz]]></dc:creator>
		<pubDate>Wed, 02 Sep 2009 11:16:34 +0000</pubDate>
		<guid isPermaLink="false">http://thejoysofcomputing.wordpress.com/?p=54#comment-14</guid>
		<description><![CDATA[Thanks for noticing, Corrected. Yeah, I&#039;ll look into the documentation.]]></description>
		<content:encoded><![CDATA[<p>Thanks for noticing, Corrected. Yeah, I&#8217;ll look into the documentation.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
