<?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>Marius van Witzenburg &#187; Backticks</title>
	<atom:link href="http://kitara.nl/tag/backticks/feed/" rel="self" type="application/rss+xml" />
	<link>http://kitara.nl</link>
	<description>We fight for our survival, we fight!</description>
	<lastBuildDate>Sun, 20 May 2012 15:39:19 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>How to use the exec() and system() function and capture the returned output in Perl</title>
		<link>http://kitara.nl/2011/06/14/how-to-use-the-exec-and-system-function-and-capture-the-returned-output-in-perl/</link>
		<comments>http://kitara.nl/2011/06/14/how-to-use-the-exec-and-system-function-and-capture-the-returned-output-in-perl/#comments</comments>
		<pubDate>Tue, 14 Jun 2011 19:11:14 +0000</pubDate>
		<dc:creator>mariusvw</dc:creator>
				<category><![CDATA[BSD / Linux / Unix]]></category>
		<category><![CDATA[How to]]></category>
		<category><![CDATA[Backticks]]></category>
		<category><![CDATA[Exec]]></category>
		<category><![CDATA[Output]]></category>
		<category><![CDATA[Perl]]></category>
		<category><![CDATA[System]]></category>

		<guid isPermaLink="false">http://kitara.nl/?p=334</guid>
		<description><![CDATA[When you want to execute a program you sometimes want to use the result of the program you executed. exec&#40;PROGRAM&#41;; $result = system&#40;PROGRAM&#41;; Both Perl's exec() function and system() function execute a system shell command. The big difference is that system() creates a fork process and waits to see if the command succeeds or fails [...]]]></description>
			<content:encoded><![CDATA[<p>When you want to execute a program you sometimes want to use the result of the program you executed.</p>

<div class="wp_syntax"><div class="code"><pre class="perl" style="font-family:monospace;"><span style="color: #000066;">exec</span><span style="color: #009900;">&#40;</span>PROGRAM<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #0000ff;">$result</span> <span style="color: #339933;">=</span> <span style="color: #000066;">system</span><span style="color: #009900;">&#40;</span>PROGRAM<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Both Perl's <strong>exec()</strong> function and <strong>system()</strong> function execute a system shell command. The big difference is that <strong>system()</strong> creates a fork process and waits to see if the command succeeds or fails - returning a value. <strong>exec()</strong> does not return anything, it simply executes the command. Neither of these commands should be used to capture the output of a system call. If your goal is to capture output, you should use the <strong>backtick operator</strong>:</p>

<div class="wp_syntax"><div class="code"><pre class="perl" style="font-family:monospace;"><span style="color: #0000ff;">$result</span> <span style="color: #339933;">=</span> <span style="color: #ff0000;">`PROGRAM`</span><span style="color: #339933;">;</span></pre></div></div>

<p>Found this information in a post by <a href="http://perl.about.com/bio/Kirk-Brown-16393.htm">Kirk Brown</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://kitara.nl/2011/06/14/how-to-use-the-exec-and-system-function-and-capture-the-returned-output-in-perl/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

