<?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>trim | /var/logs/paulooi.log</title>
	<atom:link href="https://logs.paulooi.com/tag/trim/feed" rel="self" type="application/rss+xml" />
	<link>https://logs.paulooi.com</link>
	<description>Systems Admin, Web Development and etc</description>
	<lastBuildDate>Tue, 13 Jul 2010 01:06:47 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	
	<item>
		<title>Perl, Trim White Space from a String</title>
		<link>https://logs.paulooi.com/perl-trim-white-space-from-a-string.php</link>
					<comments>https://logs.paulooi.com/perl-trim-white-space-from-a-string.php#comments</comments>
		
		<dc:creator><![CDATA[Paul Ooi]]></dc:creator>
		<pubDate>Tue, 13 Jul 2010 01:06:47 +0000</pubDate>
				<category><![CDATA[Systems]]></category>
		<category><![CDATA[perl]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[string]]></category>
		<category><![CDATA[trim]]></category>
		<guid isPermaLink="false">http://systems.takizo.com/?p=1026</guid>

					<description><![CDATA[<p>When we grep a bunch of string, there are white spaces where we wish to trim, especially the white space at the beginning and the end of a string. There is no trim function in Perl like trim in PHP....</p>
The post <a href="https://logs.paulooi.com/perl-trim-white-space-from-a-string.php">Perl, Trim White Space from a String</a> first appeared on <a href="https://logs.paulooi.com">/var/logs/paulooi.log</a>.]]></description>
										<content:encoded><![CDATA[<p>When we grep a bunch of string, there are white spaces where we wish to trim, especially the white space at the beginning and the end of a string. There is no trim function in Perl like trim in PHP. The Perl function below should help you to trim the string. </p>
<pre>
<code>
#!/usr/bin/perl


sub trim($);
sub ltrim($);
sub rtrim($);

sub trim($)
{
	my $trim_string = shift;
	$trim_string =~ s/^\s+//;
	$trim_string =~ s/\s+$//;
	return $trim_string;
}

sub ltrim($)
{
	my $trim_string = shift;
	$trim_string =~ s/^\s+//;
	return $trim_string;
}

sub rtrim($)
{
	my $trim_string = shift;
	$trim_string =~ s/\s+$//;
	return $trim_string;
}

my $long_string = "  \t  foo foo        bar \t \t bar          ";
print trim($long_string);
</code>
</pre>The post <a href="https://logs.paulooi.com/perl-trim-white-space-from-a-string.php">Perl, Trim White Space from a String</a> first appeared on <a href="https://logs.paulooi.com">/var/logs/paulooi.log</a>.]]></content:encoded>
					
					<wfw:commentRss>https://logs.paulooi.com/perl-trim-white-space-from-a-string.php/feed</wfw:commentRss>
			<slash:comments>2</slash:comments>
		
		
			</item>
	</channel>
</rss>
