<?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>RedHatVN Network &#187; perl</title>
	<atom:link href="http://redhatvn.net/tag/perl/feed" rel="self" type="application/rss+xml" />
	<link>http://redhatvn.net</link>
	<description>Shared Linux problems</description>
	<lastBuildDate>Mon, 31 Oct 2011 07:10:57 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>How to Search and Replace over Multiple Files in Linux</title>
		<link>http://redhatvn.net/how-to-search-and-replace-over-multiple-files-in-linux</link>
		<comments>http://redhatvn.net/how-to-search-and-replace-over-multiple-files-in-linux#comments</comments>
		<pubDate>Wed, 13 Jan 2010 05:39:04 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Centos]]></category>
		<category><![CDATA[Cpanel]]></category>
		<category><![CDATA[Directadmin]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[vps]]></category>
		<category><![CDATA[perl]]></category>

		<guid isPermaLink="false">http://redhatvn.net/?p=1060</guid>
		<description><![CDATA[Sometimes you need to search and replace strings over multiple files. This can easily be done using perl. I found this tip from www.liamdelahunty.com/tips perl -pi -w -e 's/search/replace/g;' *.php -e means execute the following line of code. -i means edit in-place -w write warnings -p loop]]></description>
			<content:encoded><![CDATA[<div class="google_plus_one"><g:plusone size="medium" count="true" url="http://redhatvn.net/how-to-search-and-replace-over-multiple-files-in-linux"></g:plusone></div><p>Sometimes you need to search and replace strings over multiple files. This can easily be done using perl. I found this tip from www.liamdelahunty.com/tips<br />
<span id="more-1060"></span><br />
<code>perl -pi -w -e 's/search/replace/g;' *.php</code></p>
<p>-e means execute the following line of code.<br />
-i means edit in-place<br />
-w write warnings<br />
-p loop</p>
]]></content:encoded>
			<wfw:commentRss>http://redhatvn.net/how-to-search-and-replace-over-multiple-files-in-linux/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>There was an error when you login Cpanel</title>
		<link>http://redhatvn.net/cpanel-error</link>
		<comments>http://redhatvn.net/cpanel-error#comments</comments>
		<pubDate>Sat, 19 Dec 2009 01:53:02 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Centos]]></category>
		<category><![CDATA[Cpanel]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[vps]]></category>
		<category><![CDATA[perl]]></category>

		<guid isPermaLink="false">http://redhatvn.net/?p=909</guid>
		<description><![CDATA[There was an error when you login Cpanel Can&#8217;t locate GDBM_File.pm in @INC (@INC contains: /usr/local/cpanel /usr/local/cpanel/perl /usr/local/cpanel/Cpanel/CPAN/overload/__Digest /usr/local/cpanel/build-tools/stubs /usr/lib/perl5/5.6.2/i686-linux /usr/lib/perl5/5.6.2 /usr/lib/perl5/site_perl/5.6.2/i686-linux /usr/lib/perl5/site_perl/5.6.2 /usr/lib/perl5/site_perl .) at /usr/local/cpanel/Cpanel/Locale/Utils.pm line 14. Cpanel::Locale::Utils::BEGIN() called at GDBM_File.pm line 14 eval {&#8230;} called at GDBM_File.pm line 14 require Cpanel/Locale/Utils.pm called at /usr/local/cpanel/Cpanel/Locale.pm line 15 Cpanel::Locale::BEGIN() called at GDBM_File.pm line 14 [...]]]></description>
			<content:encoded><![CDATA[<div class="google_plus_one"><g:plusone size="medium" count="true" url="http://redhatvn.net/cpanel-error"></g:plusone></div><p>There was an error when you login Cpanel</p>
<blockquote><p>Can&#8217;t locate GDBM_File.pm in @INC (@INC contains: /usr/local/cpanel /usr/local/cpanel/perl /usr/local/cpanel/Cpanel/CPAN/overload/__Digest /usr/local/cpanel/build-tools/stubs /usr/lib/perl5/5.6.2/i686-linux /usr/lib/perl5/5.6.2 /usr/lib/perl5/site_perl/5.6.2/i686-linux /usr/lib/perl5/site_perl/5.6.2 /usr/lib/perl5/site_perl .) at /usr/local/cpanel/Cpanel/Locale/Utils.pm line 14.<br />
Cpanel::Locale::Utils::BEGIN() called at GDBM_File.pm line 14<br />
eval {&#8230;} called at GDBM_File.pm line 14<br />
require Cpanel/Locale/Utils.pm called at /usr/local/cpanel/Cpanel/Locale.pm line 15<br />
Cpanel::Locale::BEGIN() called at GDBM_File.pm line 14<br />
eval {&#8230;} called at GDBM_File.pm line 14<br />
require Cpanel/Locale.pm called at /usr/local/cpanel/Cpanel/StatsBar.pm line 11<br />
Cpanel::StatsBar::BEGIN() called at GDBM_File.pm line 14<br />
eval {&#8230;} called at GDBM_File.pm line 14<br />
require Cpanel/StatsBar.pm called at (eval 74) line 1<br />
main::BEGIN() called at GDBM_File.pm line 14<br />
eval {&#8230;} called at GDBM_File.pm line 14<br />
eval &#8216;use Cpanel::StatsBar ();&#8217; called at cpanel.pl line 4974<br />
main::modloader(&#8216;StatsBar&#8217;) called at /usr/local/cpanel/Cpanel/LoadModule.pm line 10<br />
Cpanel::LoadModule::loadmodule(&#8216;StatsBar&#8217;) called at cpanel.pl line 4982<br />
main::api2_preexec(&#8216;StatsBar&#8217;, &#8216;rowcounter&#8217;) called at cpanel.pl line 1451<br />
main::cpexectag(&#8216;&lt;?cp StatsBar::rowcounter(%,rowtype) rowcounter=mainstats ?&gt;&#8217;) called at cpanel.pl line 4808<br />
main::dotag(undef) called at cpanel.pl line 4691<br />
main::cpanel_parseblock(&#8216;SCALAR(0xa93311c)&#8217;) called at cpanel.pl line 4643<br />
main::cpanel_parse(&#8216;GLOB(0xa514874)&#8217;) called at cpanel.pl line 2878<br />
main::doinclude(&#8216;/usr/local/cpanel/base/frontend/x3/branding//index.html&#8217;, 0, 1) called at /usr/local/cpanel/Cpanel/Branding.pm line 95<br />
Cpanel::Branding::Branding_include(&#8216;index.html&#8217;) called at (eval 7) line 1<br />
eval &#8216;Cpanel::Branding::Branding_include(@{$argref});&#8217; called at cpanel.pl line 1660<br />
main::exectag(&#8216;&lt;cpanel Branding=&#8221;include(index.html)&#8221;&gt;&#8217;) called at cpanel.pl line 4808<br />
main::dotag(undef) called at cpanel.pl line 4691<br />
main::cpanel_parseblock(&#8216;SCALAR(0x91a0700)&#8217;) called at cpanel.pl line 4643<br />
main::cpanel_parse(&#8216;GLOB(0xa4d4110)&#8217;) called at cpanel.pl line 1318</p></blockquote>
<p>because there are some errors in PERL<br />
resolve<br />
</strong><br />
<code>/scripts/checkperlmodules<br />
/scripts/perlinstaller --force Encode<br />
/scripts/upcp --force</code><br />
</strong></p>
]]></content:encoded>
			<wfw:commentRss>http://redhatvn.net/cpanel-error/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Lighttpd Setup CGI-BIG CGI For Perl Programs</title>
		<link>http://redhatvn.net/lighttpd-setup-cgi-big-cgi-for-perl-programs</link>
		<comments>http://redhatvn.net/lighttpd-setup-cgi-big-cgi-for-perl-programs#comments</comments>
		<pubDate>Wed, 02 Dec 2009 08:05:30 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Centos]]></category>
		<category><![CDATA[Cpanel]]></category>
		<category><![CDATA[Directadmin]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[shell script]]></category>
		<category><![CDATA[vps]]></category>
		<category><![CDATA[Lighttpd]]></category>
		<category><![CDATA[perl]]></category>

		<guid isPermaLink="false">http://redhatvn.net/?p=675</guid>
		<description><![CDATA[httpd has mod_cgi module that allows you running Perl and other server side programs via cgi-bin directory. The Common Gateway Interface (CGI) is a standard protocol for interfacing external application software with an information server. Step #1: Create a CGI cgi-bin Directory First you need to create a cgi-bin directory for your domain. Assuming that [...]]]></description>
			<content:encoded><![CDATA[<div class="google_plus_one"><g:plusone size="medium" count="true" url="http://redhatvn.net/lighttpd-setup-cgi-big-cgi-for-perl-programs"></g:plusone></div><p>httpd has mod_cgi module that allows you running Perl and other server side programs via cgi-bin directory. The Common Gateway Interface (CGI) is a standard protocol for interfacing external application software with an information server.<br />
<span id="more-675"></span></p>
<h2>Step #1: Create a CGI cgi-bin Directory</h2>
<p>First you need to create a cgi-bin directory for your domain. Assuming that your domain hosted at /home/lighttpd/theos.in/http (DocumentRoot), create cgi-bin as follows:<br />
<code># mkdir -p /home/lighttpd/theos.in/cgi-bin</code></p>
<h2>Step # 2: Load mod_cgi Module</h2>
<p>Open lighttpd configuration file using a text editor such as vi:<br />
<code># vi  /etc/lighttpd/ligttpd.conf</code></p>
<p>Now append or modify text as follows so that support for mod_cgi get loaded:</p>
<blockquote><p>server.modules += <span>(</span> <span style="color: #993333;">&#8220;mod_cgi&#8221;</span> <span>)</span></p></blockquote>
<p>Find out your virtual server configuration and append the following:</p>
<blockquote><p>$HTTP<span>[</span><span style="color: #993333;">"url"</span><span>]</span> =~ <span style="color: #993333;">&#8220;/cgi-bin/&#8221;</span> <span>{</span><br />
      cgi.<span style="color: #000099;">assign </span>=<span style="color: #660066;"> <span>(</span> </span><span style="color: #993333;">&#8220;.pl&#8221;</span> =&gt; <span style="color: #993333;">&#8220;/usr/bin/perl&#8221;</span> <span>)</span><br />
<span>}</span></p></blockquote>
<p>Here is complete my config code:</p>
<blockquote><p>$HTTP["host"]  =~ &#8220;theos.in&#8221; {<br />
  server.document-root = &#8220;/home/lighttpd/theos.in/http&#8221;<br />
  accesslog.filename         = &#8220;/var/log/lighttpd/theos.in/access.log&#8221;<br />
  $HTTP["url"] =~ &#8220;/cgi-bin/&#8221; {<br />
      cgi.assign = ( &#8220;.pl&#8221; =&gt; &#8220;/usr/bin/perl&#8221; )<br />
  }<br />
}</p></blockquote>
<h3>Step # 3:Restart the Lighttpd</h3>
<p>Restart lighttpd webserver, enter:<br />
<code># /etc/init.d/lighttpd restart</code></p>
<h3>Step # 4: Test It</h3>
<p>Create a file/perl program in /home/lighttpd/theos.in/cgi-bin/sample.pl:</p>
<blockquote><p><span style="color: #808080; font-style: italic;">#!/usr/bin/perl</span><br />
<a href="http://perldoc.perl.org/functions/print.html"><span style="color: #000066;">print</span></a> <span style="color: #ff0000;">&#8220;Content-Type: text/plain&#8221;</span>, <span style="color: #ff0000;">&#8220;<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\n</span>&#8220;</span>;<br />
<a href="http://perldoc.perl.org/functions/print.html"><span style="color: #000066;">print</span></a> <span style="color: #ff0000;">&#8220;Hi there! This is a sample perl program!!!&#8221;</span>, <span style="color: #ff0000;">&#8220;<span style="color: #000099; font-weight: bold;">\n</span>&#8220;</span>;</p></blockquote>
<p>Save and execute the program (http://yourdomain.com/cgi-bin/sample.pl).</p>
]]></content:encoded>
			<wfw:commentRss>http://redhatvn.net/lighttpd-setup-cgi-big-cgi-for-perl-programs/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Bash Shell: Replace a string with another string in all files using sed and perl -pie</title>
		<link>http://redhatvn.net/bash-shell-replace-a-string-with-another-string-in-all-files-using-sed-and-perl-pie</link>
		<comments>http://redhatvn.net/bash-shell-replace-a-string-with-another-string-in-all-files-using-sed-and-perl-pie#comments</comments>
		<pubDate>Thu, 27 Aug 2009 09:22:03 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[shell script]]></category>
		<category><![CDATA[perl]]></category>
		<category><![CDATA[sed]]></category>

		<guid isPermaLink="false">http://redhatvn.net/?p=269</guid>
		<description><![CDATA[Q. How do I replace a string with another string in all files? For example, ~/foo directory has 100s of text file and I&#8217;d like to find out xyz string and replace with abc. I&#8217;d like to use sed or any other tool to replace all occurrence of the word. A.sed command is designed for [...]]]></description>
			<content:encoded><![CDATA[<div class="google_plus_one"><g:plusone size="medium" count="true" url="http://redhatvn.net/bash-shell-replace-a-string-with-another-string-in-all-files-using-sed-and-perl-pie"></g:plusone></div><p><span style="color: #ff0000;">Q.</span> How do I replace a string with another string in all files? For example, ~/foo directory has 100s of text file and I&#8217;d like to find out xyz string and replace with abc. I&#8217;d like to use sed or any other tool to replace all occurrence of the word.</p>
<p><span style="color: #009900;">A</span>.sed command is designed for this kind of work i.e. replace strings.</p>
<p><span id="more-269"></span></p>
<h2>sed replace word / string syntax</h2>
<p><code>sed -i 's/<span style="color: #ff0000;">old-word</span>/<span style="color: #993399;">new-word</span>/g' *.txt</code></p>
<p>GNU sed command can edit files in place (makes backup if extension supplied) using -i option. If you are using old or UNIX sed command try the following syntax:</p>
<p><code>sed 's/<span style="color: #993399;">old</span>/<span style="color: #ff9900;">new</span>/g' input.txt &gt; output.txt</code></p>
<p>I recommend using old syntax along with for loop:</p>
<blockquote><p>
#!/bin/bash<br />
OLD=&#8221;xyz&#8221;<br />
NEW=&#8221;abc&#8221;<br />
DPATH=&#8221;/home/you/foo/*.txt&#8221;<br />
BPATH=&#8221;/home/you/bakup/foo&#8221;<br />
TFILE=&#8221;/tmp/out.tmp.$$&#8221;<br />
[ ! -d $BPATH ] &amp;&amp; mkdir -p $BPATH || :<br />
for f in $DPATH<br />
do<br />
  if [ -f $f -a -r $f ]; then<br />
    /bin/cp -f $f $BPATH<br />
   sed &#8220;s/$OLD/$NEW/g&#8221; &#8220;$f&#8221; &gt; $TFILE &amp;&amp; mv $TFILE &#8220;$f&#8221;<br />
  else<br />
   echo &#8220;Error: Cannot read $f&#8221;<br />
  fi<br />
done<br />
/bin/rm $TFILE</p></blockquote>
<h2>perl -pie trick</h2>
<p><code>perl -pie 's/<span style="color: #993399;">old-word</span>/<span style="color: #ff9900;">new-word</span>/g' input &gt; output</code></p>
]]></content:encoded>
			<wfw:commentRss>http://redhatvn.net/bash-shell-replace-a-string-with-another-string-in-all-files-using-sed-and-perl-pie/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
<!-- WP Super Cache is installed but broken. The path to wp-cache-phase1.php in wp-content/advanced-cache.php must be fixed! -->
