<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Easy Ruby On Rails Programming &#187; Perl</title>
	<atom:link href="http://easyrubyonrailsprogramming.com/tag/perl/feed/" rel="self" type="application/rss+xml" />
	<link>http://easyrubyonrailsprogramming.com</link>
	<description>The Place to be to Learn Ruby On Rails</description>
	<lastBuildDate>Sat, 24 Dec 2011 05:30:24 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
		<item>
		<title>Perl Differences in string handling</title>
		<link>http://easyrubyonrailsprogramming.com/development/perl-differences-in-string-handling/</link>
		<comments>http://easyrubyonrailsprogramming.com/development/perl-differences-in-string-handling/#comments</comments>
		<pubDate>Mon, 21 Apr 2008 03:52:35 +0000</pubDate>
		<dc:creator>Avatar</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Programming Basics]]></category>
		<category><![CDATA[Perl]]></category>
		<category><![CDATA[strings]]></category>

		<guid isPermaLink="false">http://easyrubyonrailsprogramming.com/development/perl-differences-in-string-handling/</guid>
		<description><![CDATA[A note to Perl users, strings that contain numbers will not be automatically converted to numbers when used in an expression such as when trying to read numbers from a file like the one below does. DATA.each do &#124;line&#124; vals = line.split # split line, storing tokens in val print vals[0] + vals[1], &#8221; &#8221; [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.wellho.net/picture/tclstrings.html"><img src="/wp-content/uploads/scraped/37.jpg"/></a>
<p>A note to Perl users, strings that contain numbers will not be automatically converted to numbers when used in an expression such as when trying to read numbers from a file like the one below does.</p>
<p>DATA.each do |line|<br />
   vals = line.split    # split line, storing tokens in val<br />
   print vals[0] + vals[1], &#8221; &#8221;<br />
end</p>
<p>If you use a file as input that contains,</p>
<p>2 8<br />
9 6<br />
1 4</p>
<p>You&#8217;ll end up with; 28, 96 and 14 where they were treated as strings and not numbers. Using the string#to_i method which converts the string into an integer you get the desired result.</p>
<p>Sample for string#to_i string to integer conversion</p>
<p>DATA.each do |line|<br />
   vals = line.split    # split line, storing tokens in val<br />
   print vals[0].to_i + vals[1].to_i, &#8221; &#8221;<br />
end</p>
<p>Yielding the right answers; 10 15 5</p>
]]></content:encoded>
			<wfw:commentRss>http://easyrubyonrailsprogramming.com/development/perl-differences-in-string-handling/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

