<?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>TikiRobot! &#187; perl</title>
	<atom:link href="http://www.tikirobot.net/wp/tag/perl/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.tikirobot.net/wp</link>
	<description>Mai Tais and Blinky Lights, Ahoy!</description>
	<lastBuildDate>Wed, 01 Feb 2012 22:14:15 +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>Perl is a Shinto Shrine</title>
		<link>http://www.tikirobot.net/wp/2008/12/13/perl-is-a-shinto-shrine/</link>
		<comments>http://www.tikirobot.net/wp/2008/12/13/perl-is-a-shinto-shrine/#comments</comments>
		<pubDate>Sat, 13 Dec 2008 21:50:03 +0000</pubDate>
		<dc:creator>rajbot</dc:creator>
				<category><![CDATA[video]]></category>
		<category><![CDATA[ClayShirky]]></category>
		<category><![CDATA[perl]]></category>
		<category><![CDATA[shinto]]></category>

		<guid isPermaLink="false">http://www.tikirobot.net/wp/?p=2150</guid>
		<description><![CDATA[I love this little talk Clay Shirky gave at Supernova 2007: &#8220;The Imbe Priests would totally get Linux!&#8221; via reddit.]]></description>
			<content:encoded><![CDATA[<p>I love this little talk Clay Shirky gave at Supernova 2007:<br />
<object width="480" height="385"><param name="movie" value="http://www.youtube.com/v/Xe1TZaElTAs&#038;hl=en&#038;fs=1&#038;rel=0"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/Xe1TZaElTAs&#038;hl=en&#038;fs=1&#038;rel=0" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="480" height="385"></embed></object><br />
&#8220;The Imbe Priests would totally get Linux!&#8221; via <a href="http://www.reddit.com/r/programming/comments/7jb5p/clay_shriky_on_shinto_perl_love_and_the_internet/">reddit</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.tikirobot.net/wp/2008/12/13/perl-is-a-shinto-shrine/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>I can haz complier??????</title>
		<link>http://www.tikirobot.net/wp/2008/08/20/i-can-haz-complier/</link>
		<comments>http://www.tikirobot.net/wp/2008/08/20/i-can-haz-complier/#comments</comments>
		<pubDate>Wed, 20 Aug 2008 17:35:42 +0000</pubDate>
		<dc:creator>rajbot</dc:creator>
				<category><![CDATA[code code]]></category>
		<category><![CDATA[lolcode]]></category>
		<category><![CDATA[parrot]]></category>
		<category><![CDATA[perl]]></category>
		<category><![CDATA[wtf???]]></category>

		<guid isPermaLink="false">http://www.tikirobot.net/wp/?p=1714</guid>
		<description><![CDATA[Here is a lightning talk by Partick Michaud at YAPC::Europe 2008 in Copenhagen, demonstrating the Parrot Compiler Toolkit. Live demo: a LOLCODE compiler. wut? It would be really nice if we can take all these languages, pass them through Parrot, and translate them to other languages. I decided that wasn&#8217;t good enough. Let&#8217;s just translate [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://blip.tv/file/1188001/">Here</a> is a lightning talk by Partick Michaud at YAPC::Europe 2008 in Copenhagen, demonstrating the Parrot Compiler Toolkit. Live demo: a LOLCODE compiler. wut?</p>
<blockquote><p>It would be really nice if we can take all these languages, pass them through Parrot, and translate them to other languages. I decided that wasn&#8217;t good enough. Let&#8217;s just translate them to LOLCODE.</p></blockquote>
<p>video:<br />
<embed src="http://blip.tv/play/Acjxf47dBw" type="application/x-shockwave-flash" width="500" height="420" allowscriptaccess="always" allowfullscreen="true"></embed> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.tikirobot.net/wp/2008/08/20/i-can-haz-complier/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Example Scripts: REST web services and system calls</title>
		<link>http://www.tikirobot.net/wp/2007/03/18/example-scripts-rest-web-services-and-system-calls/</link>
		<comments>http://www.tikirobot.net/wp/2007/03/18/example-scripts-rest-web-services-and-system-calls/#comments</comments>
		<pubDate>Sun, 18 Mar 2007 09:35:02 +0000</pubDate>
		<dc:creator>rajbot</dc:creator>
				<category><![CDATA[code code]]></category>
		<category><![CDATA[example scripts]]></category>
		<category><![CDATA[perl]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://www.tikirobot.net/wp/2007/03/18/example-scripts-rest-web-services-and-system-calls/</guid>
		<description><![CDATA[I&#8217;ve been translating all the new perl and php scripts I write into Python and Ruby in order to learn more about those two languages. I checked some more example scripts into SourceForge, which might be useful for others who know one of these languages and want to learn a new one. These scripts are [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been translating all the new perl and php scripts I write into Python and Ruby in order to learn more about those two languages. I checked some more example scripts into SourceForge, which might be useful for others who know one of these languages and want to learn a new one.</p>
<p>These scripts are available in perl, php, python, and ruby:<br />
<UL>
<li> <a href="http://tikitasks.svn.sourceforge.net/viewvc/tikitasks/ExampleScripts/RESTWebService/">How to query a REST web api</a> using HTTP GET and parsing the XML response.
<li> <a href="http://tikitasks.svn.sourceforge.net/viewvc/tikitasks/ExampleScripts/SystemCall/">How to make a system call</a> and read the return value.<br />
</UL><br />
The REST Web Service PHP and Perl scripts don&#8217;t work in Mac OS X, because OS X doesn&#8217;t ship with Perl&#8217;s XML::Simple or PHP&#8217;s simplexml. More surprisingly, OS X doesn&#8217;t ship with Perl&#8217;s <a href="http://search.cpan.org/~gaas/libwww-perl-5.805/lib/LWP.pm">LWP module</a>.</p>
<p>I&#8217;m starting to like Ruby more every day. It would be nice if Ruby and Python had a XML::Simple equivalent in their standard distributions.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.tikirobot.net/wp/2007/03/18/example-scripts-rest-web-services-and-system-calls/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Example scripts: directory listing in perl, php, python, and ruby</title>
		<link>http://www.tikirobot.net/wp/2007/03/15/example-scripts-directory-listing-in-perl-php-python-and-ruby/</link>
		<comments>http://www.tikirobot.net/wp/2007/03/15/example-scripts-directory-listing-in-perl-php-python-and-ruby/#comments</comments>
		<pubDate>Thu, 15 Mar 2007 08:36:17 +0000</pubDate>
		<dc:creator>rajbot</dc:creator>
				<category><![CDATA[code code]]></category>
		<category><![CDATA[example scripts]]></category>
		<category><![CDATA[perl]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://www.tikirobot.net/wp/2007/03/15/example-scripts-directory-listing-in-perl-php-python-and-ruby/</guid>
		<description><![CDATA[I remember when I fell in love with Perl. It was the summer of 1995, and peliom and I had just met, and were working at the Lab. Postscript hacking using MacPerl on OS 8. It was beautiful. That was more than ten years ago, and even though I&#8217;ve remained a Perl hacker the whole [...]]]></description>
			<content:encoded><![CDATA[<p>I remember when I fell in love with Perl. It was the summer of 1995, and peliom and I had just met, and were working at the Lab. Postscript hacking using MacPerl on OS 8. It was beautiful. </p>
<p>That was more than ten years ago, and even though I&#8217;ve remained a Perl hacker the whole time, I see massive amounts of development happening on Python and Ruby, and the Perl community seems to be slowing down (what&#8217;s up with Perl 6 anyway?), so, despite the lack of block-level scope, I think it might finally be time to move on.</p>
<p>I don&#8217;t know enough about either Python or Ruby to figure out which to learn, so I&#8217;ll learn them both, and deal with choosing one later. Along the way I&#8217;ll post some example scripts. Anyone else making the jump from Perl or PHP to something modern might find these useful. Here is the first example: printing out a directory listing using readdir and glob in your favorite scripting language:</p>
<p><span id="more-967"></span></p>
<p>[perl]<br />
<OL>
<li>!/usr/bin/perl<br />
</OL>use strict;<br />
use warnings;</p>
<p>my $dir = &#8216;/&#8217;;</p>
<p><OL>
<li> Use readdir
<li>_______________________________________________________________________________<br />
</OL>print &#8220;Directory listing in perl of $dir using readdir\n&#8221;;<br />
opendir(HANDLE, $dir) or die &#8220;Cannot opendir $dir: $!&#8221;;<br />
foreach my $file (readdir(HANDLE)) {<br />
    print &#8220;\t$file\n&#8221;;<br />
}<br />
closedir(HANDLE);</p>
<p><OL>
<li> Use globbing
<li>_______________________________________________________________________________<br />
</OL>print &#8220;Directory listing in perl of $dir using globbing\n&#8221;;<br />
foreach my $file (glob(&#8220;/*&#8221;)) {<br />
    print &#8220;\t$file\n&#8221;;<br />
}<br />
[/perl]</p>
<p>[python]<br />
<OL>
<li>!/usr/bin/python<br />
</OL><br />
import os<br />
import dircache<br />
import glob</p>
<p>dir = &#8220;/&#8221;</p>
<p><OL>
<li> Use os.listdir
<li>_______________________________________________________________________________<br />
</OL>print &#8220;Directory listing in python of &#8221; + dir + &#8221; using os.listdir&#8221;<br />
files = os.listdir(dir)<br />
for file in files:<br />
    print &#8220;\t&#8221; + file</p>
<p><OL>
<li> Use dircache
<li>_______________________________________________________________________________<br />
</OL>print &#8220;Directory listing in python of &#8221;  + dir + &#8221; using dircache&#8221;<br />
files = dircache.listdir(dir)<br />
for file in files:<br />
    print &#8220;\t&#8221; + file</p>
<p><OL>
<li> Use glob
<li>_______________________________________________________________________________<br />
</OL>print &#8220;Directory listing in python of &#8221;  + dir + &#8221; using glob&#8221;<br />
files = glob.glob(&#8220;/*&#8221;)<br />
for file in files:<br />
    print &#8220;\t&#8221; + file<br />
[/python]</p>
<p>[ruby]<br />
<OL>
<li>!/usr/bin/ruby<br />
</OL><br />
dir = &#8220;/&#8221;</p>
<p><OL>
<li> Use foreach
<li>_______________________________________________________________________________<br />
</OL>print &#8220;Directory listing in ruby of #{dir} using Dir.foreach\n&#8221;<br />
Dir.foreach(dir) {|file| print &#8220;\t#{file}\n&#8221; }</p>
<p><OL>
<li> Use glob
<li>_______________________________________________________________________________<br />
</OL>print &#8220;Directory listing in ruby of #{dir} using Dir.glob\n&#8221;<br />
files = Dir.glob(&#8220;/*&#8221;)<br />
files.each do |file| print &#8220;\t#{file}\n&#8221; end<br />
[/ruby]</p>
<p>These scripts, as well as a PHP version, are checked in <a href="http://tikitasks.svn.sourceforge.net/viewvc/tikitasks/ExampleScripts/DirectoryListing/">at SourceForge</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.tikirobot.net/wp/2007/03/15/example-scripts-directory-listing-in-perl-php-python-and-ruby/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Updating Twitter via iChat or AIM status message</title>
		<link>http://www.tikirobot.net/wp/2006/09/24/updating-twitter-via-ichat-or-aim-status-message/</link>
		<comments>http://www.tikirobot.net/wp/2006/09/24/updating-twitter-via-ichat-or-aim-status-message/#comments</comments>
		<pubDate>Sun, 24 Sep 2006 07:54:14 +0000</pubDate>
		<dc:creator>rajbot</dc:creator>
				<category><![CDATA[code code]]></category>
		<category><![CDATA[perl]]></category>

		<guid isPermaLink="false">http://www.tikirobot.net/wp/2006/09/24/updating-twitter-via-ichat-or-aim-status-message/</guid>
		<description><![CDATA[Update: Here is a Cocoa version that is easier to use! May did a good job selling us on Twitter, so now you can see my twittr status in the sidebar.. I wished that changing my Twitter status was as easy as changing my iChat status, so I hacked up this bit of perl that [...]]]></description>
			<content:encoded><![CDATA[<p><b>Update:</b> Here is a <a href="http://www.tikirobot.net/wp/2007/01/29/update-twitter-via-ichat-status-message-part-ii/">Cocoa version that is easier to use!</a></p>
<p>May did a good job selling us on <a href="http://twitter.com/">Twitter</a>, so now you can see my twittr status in the sidebar.. I wished that changing my Twitter status was as easy as changing my iChat status, so I hacked up this bit of perl that will update it when your iChat status changes. It runs every five minutes via launchd, and uses the newly-announced <a href="http://twitter.com/help/api">Twitter API</a>.</p>
<p>[perl]#!/usr/bin/perl<br />
use strict;<br />
use warnings;<br />
use URI::Escape;</p>
<p>my $user = &#8216;user@example.com&#8217;;<br />
my $pass = &#8216;pin&#8217;;</p>
<p>my $isAvailable = `osascript -e &#8216;tell application &#8220;iChat&#8221; to status&#8217;`;<br />
chomp $isAvailable;</p>
<p>exit if (&#8216;available&#8217; ne $isAvailable);</p>
<p>my $status = `osascript -e &#8216;tell application &#8220;iChat&#8221; to status message&#8217;`;<br />
chomp $status;</p>
<p>if (&#8221; eq $status) {<br />
	$status = &#8216;lazy&#8217;;<br />
}</p>
<p>my $savedStatusFile = &#8216;savedStatus.txt&#8217;;</p>
<p>my $savedStatus = &#8221;;<br />
if (-e $savedStatusFile) {<br />
	$savedStatus = `cat $savedStatusFile`;<br />
}</p>
<p>if ($status ne $savedStatus) {<br />
	#status changed, update twitter</p>
<p>	my $encStatus = &#8216;status=&#8217; . uri_escape($status, &#8220;^A-Za-z0-9&#8243;); </p>
<p>	`curl -s -d &#8216;$encStatus&#8217; -u $user:$pass http://twitter.com/statuses/update.xml`;</p>
<p>	open (FILE, &#8220;>$savedStatusFile&#8221;) or die &#8220;can&#8217;t open $savedStatusFile for writing&#8221;;<br />
	print FILE $status;<br />
	close FILE;<br />
}<br />
[/perl]</p>
<p>You can get launchd to run the script every five minutes by creating a file called ~/Library/LaunchAgents/net.tikirobot.status.plist that looks like this:<br />
[xml]<br />
<?xml version="1.0" encoding="UTF-8"?><br />
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.<br />
com/DTDs/PropertyList-1.0.dtd&#8221;></p>
<plist version="1.0">
<dict><br />
    <key>Label</key><br />
    <string>net.tikirobot.status</string><br />
    <key>ProgramArguments</key><br />
    <array><br />
            <string>/Users/user/status.pl</string><br />
    </array><br />
    <key>StartInterval</key><br />
    <integer>300</integer><br />
</dict>
</plist>
[/xml]</p>
<p>And then load the job using:<br />
<code>launchctl load ~/Library/LaunchAgents/net.tikirobot.status.plist</code></p>
<p>Update: The script now uses URI::URL and POST. Fixed a typo.<br />
Update2: Now uses URI::Escape</p>
]]></content:encoded>
			<wfw:commentRss>http://www.tikirobot.net/wp/2006/09/24/updating-twitter-via-ichat-or-aim-status-message/feed/</wfw:commentRss>
		<slash:comments>17</slash:comments>
		</item>
	</channel>
</rss>

