<?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>beer planet &#187; file</title>
	<atom:link href="http://beerpla.net/tag/file/feed/" rel="self" type="application/rss+xml" />
	<link>http://beerpla.net</link>
	<description>where things have nothing to do with beer - tutorials, tips, how-tos, thoughts, hacks, and other techy nonsense</description>
	<lastBuildDate>Tue, 27 Jul 2010 04:25:48 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
	<atom:link rel='hub' href='http://beerpla.net/?pushpress=hub'/>
		<item>
		<title>How To View A Specific SVN Revision In Your Browser</title>
		<link>http://beerpla.net/2010/02/20/how-to-view-a-specific-svn-revision-in-your-browser/</link>
		<comments>http://beerpla.net/2010/02/20/how-to-view-a-specific-svn-revision-in-your-browser/#comments</comments>
		<pubDate>Sun, 21 Feb 2010 06:04:17 +0000</pubDate>
		<dc:creator>Artem Russakovskii</dc:creator>
				<category><![CDATA[SVN]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[bc]]></category>
		<category><![CDATA[browser]]></category>
		<category><![CDATA[chrome]]></category>
		<category><![CDATA[directory]]></category>
		<category><![CDATA[file]]></category>
		<category><![CDATA[Firefox]]></category>
		<category><![CDATA[internet explorer]]></category>
		<category><![CDATA[revision]]></category>
		<category><![CDATA[specific]]></category>
		<category><![CDATA[subversion]]></category>
		<category><![CDATA[trunk]]></category>
		<category><![CDATA[update]]></category>
		<category><![CDATA[view]]></category>
		<category><![CDATA[Wordpress]]></category>
		<guid isPermaLink="false">http://beerpla.net/2010/02/20/how-to-view-a-specific-svn-revision-in-your-browser/</guid>
		<description><![CDATA[<p><img style="margin: 0px 10px 10px 0px; display: inline" title="image" alt="image" align="left" src="http://beerpla.net/wp-content/uploads/2010/04/image.png" width="150" height="150" /> This is a quick recipe that I found pretty interesting and relatively unknown.</p>
<p>Everyone who uses SVN knows that most repositories are set up to allow viewing of their contents via a web browser. For example, here&#039;s the trunk of WP Plugins SVN: <a title="http://plugins.svn.wordpress.org/" href="http://plugins.svn.wordpress.org/" rel="nofollow">http://plugins.svn.wordpress.org/</a> and here is the current trunk version of a specific file, let&#039;s say <a title="http://plugins.svn.wordpress.org/stats/trunk/readme.txt" href="http://plugins.svn.wordpress.org/stats/trunk/readme.txt" rel="nofollow">http://plugins.svn.wordpress.org/stats/trunk/readme.txt</a>.</p>
<h2>The Problem</h2>
<p>However, what if you wanted to view a <strong><em>specific revision</em></strong> of a file or directory <strong><em>in your browser</em></strong>?</p>
<p>Let&#039;s say I wanted revision 100,000 of <a href="http://plugins.svn.wordpress.org/stats/trunk/readme.txt" rel="nofollow">http://plugins.svn.wordpress.org/stats/trunk/readme.txt</a></p>
<p>Normally, on a command line,...<div class=clear></div> <a href="http://beerpla.net/2010/02/20/how-to-view-a-specific-svn-revision-in-your-browser/" class="read_more"><div class=excerpt-end>Read the rest of this article &#187;</div></a></p>]]></description>
			<content:encoded><![CDATA[<p><img style="margin: 0px 10px 10px 0px; display: inline" title="image" alt="image" align="left" src="http://beerpla.net/wp-content/uploads/2010/04/image.png" width="150" height="150" /> This is a quick recipe that I found pretty interesting and relatively unknown.</p>
<p>Everyone who uses SVN knows that most repositories are set up to allow viewing of their contents via a web browser. For example, here&#039;s the trunk of WP Plugins SVN: <a title="http://plugins.svn.wordpress.org/" href="http://plugins.svn.wordpress.org/" rel="nofollow">http://plugins.svn.wordpress.org/</a> and here is the current trunk version of a specific file, let&#039;s say <a title="http://plugins.svn.wordpress.org/stats/trunk/readme.txt" href="http://plugins.svn.wordpress.org/stats/trunk/readme.txt" rel="nofollow">http://plugins.svn.wordpress.org/stats/trunk/readme.txt</a>.</p>
<h2>The Problem</h2>
<p>However, what if you wanted to view a <strong><em>specific revision</em></strong> of a file or directory <strong><em>in your browser</em></strong>?</p>
<p>Let&#039;s say I wanted revision 100,000 of <a href="http://plugins.svn.wordpress.org/stats/trunk/readme.txt" rel="nofollow">http://plugins.svn.wordpress.org/stats/trunk/readme.txt</a></p>
<p>Normally, on a command line, you&#039;d do something like</p>
<div class="wp_syntax"><div class="code"><pre>svn co http://plugins.svn.wordpress.org/stats/trunk/readme.txt stats
cd stats;
svn up -r100000 readme.txt</pre></div></div>
<p>or simply</p>
<div class="wp_syntax"><div class="code"><pre>svn export -r100000 http://plugins.svn.wordpress.org/stats/trunk/readme.txt</pre></div></div>
<p>However, how would you do this in your browser? Trying something like ?r=100000 or ?revision=100000 parameters doesn&#039;t work.</p>
<h2>The Solution</h2>
<p>Here is the syntax to get a specific revision of a file or directory:</p>
<ol>
<li>Take the root of the repository (in our case, <a href="http://plugins.svn.wordpress.org" rel="nofollow">http://plugins.svn.wordpress.org</a>) </li>
<li>Append this string <strong><em>!svn/bc/REVISION_NUMBER</em></strong> right after the repository root and before the directory or file path. </li>
</ol>
<p>Going back to our example:</p>
<ul>
<li><a href="http://plugins.svn.wordpress.org/!svn/bc/100000/stats/" rel="nofollow">http://plugins.svn.wordpress.org/!svn/bc/100000/stats/</a>
<p>shows the stats directory exactly as it was at revision 100,000 and </p>
</li>
<li><a title="http://plugins.svn.wordpress.org/!svn/bc/100000/stats/trunk/readme.txt" href="http://plugins.svn.wordpress.org/!svn/bc/100000/stats/trunk/readme.txt" rel="nofollow">http://plugins.svn.wordpress.org/!svn/bc/100000/stats/trunk/readme.txt</a>
<p>shows our readme.txt at 100,000. </p>
</li>
</ul>
<p>And that&#039;s how you do it, folks. Happy revisioning!</p>
<p><strong>Update</strong>: this post is now sponsored by <a href="http://www.wirefly.com/learn/">Wirefly Learn</a> where you can find cell phone news and reviews, as well as comparisons and videos.</p>
<div class="shr-bookmarks shr-bookmarks-expand">
<ul class="socials">
		<li class="shr-twitter">
			<a href="http://twitter.com/home?status=How+To+View+A+Specific+SVN+Revision+In+Your+Browser+-+http://bit.ly/cFiWmr&amp;source=shareaholic" rel="nofollow" class="external" title="Tweet This!">Tweet This!</a>
		</li>
		<li class="shr-facebook">
			<a href="http://www.facebook.com/share.php?v=4&amp;src=bm&amp;u=http://beerpla.net/2010/02/20/how-to-view-a-specific-svn-revision-in-your-browser/&amp;t=How+To+View+A+Specific+SVN+Revision+In+Your+Browser" rel="nofollow" class="external" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="shr-googlebuzz">
			<a href="http://www.google.com/buzz/post?url=http://beerpla.net/2010/02/20/how-to-view-a-specific-svn-revision-in-your-browser/&amp;imageurl=" rel="nofollow" class="external" title="Post on Google Buzz">Post on Google Buzz</a>
		</li>
		<li class="shr-hackernews">
			<a href="http://news.ycombinator.com/submitlink?u=http://beerpla.net/2010/02/20/how-to-view-a-specific-svn-revision-in-your-browser/&amp;t=How+To+View+A+Specific+SVN+Revision+In+Your+Browser" rel="nofollow" class="external" title="Submit this to Hacker News">Submit this to Hacker News</a>
		</li>
		<li class="shr-reddit">
			<a href="http://reddit.com/submit?url=http://beerpla.net/2010/02/20/how-to-view-a-specific-svn-revision-in-your-browser/&amp;title=How+To+View+A+Specific+SVN+Revision+In+Your+Browser" rel="nofollow" class="external" title="Share this on Reddit">Share this on Reddit</a>
		</li>
		<li class="shr-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://beerpla.net/2010/02/20/how-to-view-a-specific-svn-revision-in-your-browser/&amp;title=How+To+View+A+Specific+SVN+Revision+In+Your+Browser" rel="nofollow" class="external" title="Digg this!">Digg this!</a>
		</li>
		<li class="shr-delicious">
			<a href="http://delicious.com/post?url=http://beerpla.net/2010/02/20/how-to-view-a-specific-svn-revision-in-your-browser/&amp;title=How+To+View+A+Specific+SVN+Revision+In+Your+Browser" rel="nofollow" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="shr-stumbleupon">
			<a href="http://www.stumbleupon.com/submit?url=http://beerpla.net/2010/02/20/how-to-view-a-specific-svn-revision-in-your-browser/&amp;title=How+To+View+A+Specific+SVN+Revision+In+Your+Browser" rel="nofollow" class="external" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
		<li class="shr-mail">
			<a href="mailto:?subject=%22How%20To%20View%20A%20Specific%20SVN%20Revision%20In%20Your%20Browser%22&amp;body=Link: http://beerpla.net/2010/02/20/how-to-view-a-specific-svn-revision-in-your-browser/ (sent via shareaholic)%0D%0A%0D%0A----%0D%0A %20This%20is%20a%20quick%20recipe%20that%20I%20found%20pretty%20interesting%20and%20relatively%20unknown.%20%20Everyone%20who%20uses%20SVN%20knows%20that%20most%20repositories%20are%20set%20up%20to%20allow%20viewing%20of%20their%20contents%20via%20a%20web%20browser.%20For%20example%2C%20here%27s%20the%20trunk%20of%20WP%20Plugins%20SVN%3A%20http%3A%2F%2Fplugins.svn.wordpress.org%2F%20and%20here%20is%20the%20curr" rel="nofollow" class="external" title="Email this to a friend?">Email this to a friend?</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>
Similar Posts:<ul><li><a href="http://beerpla.net/2009/06/20/how-to-properly-set-svn-svnexternals-property-in-svn-command-line/" rel="bookmark" title="June 20, 2009">How To Properly Set SVN svn:externals Property In SVN Command Line</a></li>
<li><a href="http://beerpla.net/2008/06/16/how-to-svn-update-all-your-wordpress-plugins-in-one-go/" rel="bookmark" title="June 16, 2008">How To SVN Update All Your WordPress Plugins In One Go</a></li>
<li><a href="http://beerpla.net/2008/07/23/how-to-check-if-the-local-svn-revision-is-up-to-date/" rel="bookmark" title="July 23, 2008">How To Check If The Local SVN Revision Is Up-To-Date</a></li>
<li><a href="http://beerpla.net/2006/07/15/converting-from-cvs-to-svn-developers-notes-and-why-svn-is-better/" rel="bookmark" title="July 15, 2006">Converting from CVS to SVN: Developer&#039;s Notes And Why SVN Is Better</a></li>
<li><a href="http://beerpla.net/2008/03/29/beer-planet-upgraded-to-wordpress-25/" rel="bookmark" title="March 29, 2008">Beer Planet Upgraded To WordPress 2.5</a></li>
</ul><!-- Similar Posts took 7.119 ms --><p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save"><img src="http://beerpla.net/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a> </p>]]></content:encoded>
			<wfw:commentRss>http://beerpla.net/2010/02/20/how-to-view-a-specific-svn-revision-in-your-browser/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>[Perl] Finding Files, The Fun And Elegant Way</title>
		<link>http://beerpla.net/2009/04/08/perl-finding-files-the-fun-and-elegant-way/</link>
		<comments>http://beerpla.net/2009/04/08/perl-finding-files-the-fun-and-elegant-way/#comments</comments>
		<pubDate>Wed, 08 Apr 2009 14:00:00 +0000</pubDate>
		<dc:creator>Artem Russakovskii</dc:creator>
				<category><![CDATA[Awesomeness]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Perl]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[efficient]]></category>
		<category><![CDATA[elegant]]></category>
		<category><![CDATA[file]]></category>
		<category><![CDATA[find]]></category>
		<category><![CDATA[follow]]></category>
		<category><![CDATA[fun]]></category>
		<category><![CDATA[robust]]></category>
		<category><![CDATA[search]]></category>
		<category><![CDATA[skip]]></category>
		<category><![CDATA[SVN]]></category>
		<category><![CDATA[symlink]]></category>
		<guid isPermaLink="false">http://beerpla.net/2009/04/08/perl-finding-files-the-fun-and-elegant-way/</guid>
		<description><![CDATA[<p>No matter what programming language you use, there comes a time when you need to search for a file somewhere on the file system. Here, I want to talk about accomplishing this task in Perl. There are many ways of doing so, most of them boring, but I want to discuss the fun and elegant way &#8211; using <a href="http://search.cpan.org/dist/File-Find-Rule/lib/File/Find/Rule.pm" rel="nofollow">File::Find::Rule</a>.</p>
<p>Let me briefly discuss some of the other methods first.</p>
<h2>Limited</h2>
<p>Using glob() (or &#60;&#62;, TODO verify) you can find files in a single directory, using only the limited shell wildcard support. For example,</p>
<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre>my @files =</pre></td></tr></table></div><p>...<div class=clear></div> <a href="http://beerpla.net/2009/04/08/perl-finding-files-the-fun-and-elegant-way/" class="read_more"><div class=excerpt-end>Read the rest of this article &#187;</div></a></p>]]></description>
			<content:encoded><![CDATA[<p>No matter what programming language you use, there comes a time when you need to search for a file somewhere on the file system. Here, I want to talk about accomplishing this task in Perl. There are many ways of doing so, most of them boring, but I want to discuss the fun and elegant way &#8211; using <a href="http://search.cpan.org/dist/File-Find-Rule/lib/File/Find/Rule.pm" rel="nofollow">File::Find::Rule</a>.</p>
<p>Let me briefly discuss some of the other methods first.</p>
<h2>Limited</h2>
<p>Using glob() (or &lt;&gt;, TODO verify) you can find files in a single directory, using only the limited shell wildcard support. For example,</p>
<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre>my @files = glob(&quot;tmp*&quot;);</pre></td></tr></table></div>
<p><div class="note"><div class="noteclassic">I prefer glob() to &lt;&gt; because glob()&#039;s parameters can be more than just text (for ex functions) while &lt;&gt; treats everything inside as text.</div></div></p>
<h2>Boring</h2>
<p><a title="http://search.cpan.org/~nwclark/perl-5.8.9/lib/File/Find.pm" href="http://search.cpan.org/~nwclark/perl-5.8.9/lib/File/Find.pm">File::Find</a> is the de facto standard for searching in Perl.</p>
<p>This method finds files that end in .pl in &quot;.&quot; and &quot;../SomeDir&quot;, following symlinks:</p>
<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
</pre></td><td class="code"><pre>#!/usr/bin/perl -w
&nbsp;
use File::Find;
use Data::Dumper;
use File::Basename;
my @directories_to_search = (&quot;.&quot;, &quot;../SomeDir&quot;);
my @file_list = ();
&nbsp;
find(
  { wanted =&gt;
    sub {
      if ( basename($File::Find::name) =~ /\.pl$/i )
      {
        push @file_list, $File::Find::name;
      }
    },
    follow =&gt; 1
  },
  @directories_to_search
);
print Dumper @file_list;</pre></td></tr></table></div>
<p>It works fine, except it&#039;s horribly ugly and boring. Let&#039;s have a look at something more fun.</p>
<h2>The Fun And Elegant Way</h2>
<p><a title="http://search.cpan.org/dist/File-Find-Rule/lib/File/Find/Rule.pm" href="http://search.cpan.org/dist/File-Find-Rule/lib/File/Find/Rule.pm" rel="nofollow">File::Find::Rule</a>. Just have a look at this beauty.</p>
<p>Just like above, find all .pl files in &quot;.&quot; and &quot;../SomeDir&quot;, following symlinks:</p>
<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre>print Dumper (File::Find::Rule-&gt;name(&quot;*.pl&quot;)-&gt;file-&gt;extras({ follow =&gt; 1 })-&gt;
in(&quot;.&quot;, &quot;../SomeDir&quot;));</pre></td></tr></table></div>
<p>Same as above, except bypass .svn directories (shaves off a ton of time with a lot of directories):</p>
<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre>print Dumper (File::Find::Rule-&gt;not(File::Find::Rule-&gt;directory-&gt;name('.svn')-&gt;
prune-&gt;discard)-&gt;name(&quot;*.pl&quot;)-&gt;file-&gt;extras({ follow =&gt; 1 })-&gt;in(&quot;.&quot;, &quot;../SomeDir&quot;));</pre></td></tr></table></div>
<p>Find all .log files that are older than 24 hours in &quot;.&quot;</p>
<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code"><pre>my $epoch_time_1_day_ago = time() - 60*60*24;
print Dumper (File::Find::Rule-&gt;file-&gt;name(&quot;*.log&quot;)-&gt;
mtime(&quot;&lt;$epoch_time_1_day_ago&quot;)-&gt;in('.'));</pre></td></tr></table></div>
<p>Be sure to read the <a href="http://search.cpan.org/dist/File-Find-Rule/lib/File/Find/Rule.pm" rel="nofollow">File::Find::Rule</a> perldoc for more options and remember: have fun with your code!<a href="http://www.weblocal.ca"></a></p>
<p>Thanks to <a href="http://perlbuzz.com/" rel="nofollow">Perlbuzz</a> and Andy Lester for <a href="http://perlbuzz.com/mechanix/2008/05/optimizing-file-searches-with.html" rel="nofollow">pointing me</a> to this library a few months ago.</p>
<div class="shr-bookmarks shr-bookmarks-expand">
<ul class="socials">
		<li class="shr-twitter">
			<a href="http://twitter.com/home?status=%5BPerl%5D+Finding+Files%2C+The+Fun+And+Elegant+Way+-+http://bit.ly/caZusS&amp;source=shareaholic" rel="nofollow" class="external" title="Tweet This!">Tweet This!</a>
		</li>
		<li class="shr-facebook">
			<a href="http://www.facebook.com/share.php?v=4&amp;src=bm&amp;u=http://beerpla.net/2009/04/08/perl-finding-files-the-fun-and-elegant-way/&amp;t=%5BPerl%5D+Finding+Files%2C+The+Fun+And+Elegant+Way" rel="nofollow" class="external" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="shr-googlebuzz">
			<a href="http://www.google.com/buzz/post?url=http://beerpla.net/2009/04/08/perl-finding-files-the-fun-and-elegant-way/&amp;imageurl=" rel="nofollow" class="external" title="Post on Google Buzz">Post on Google Buzz</a>
		</li>
		<li class="shr-hackernews">
			<a href="http://news.ycombinator.com/submitlink?u=http://beerpla.net/2009/04/08/perl-finding-files-the-fun-and-elegant-way/&amp;t=%5BPerl%5D+Finding+Files%2C+The+Fun+And+Elegant+Way" rel="nofollow" class="external" title="Submit this to Hacker News">Submit this to Hacker News</a>
		</li>
		<li class="shr-reddit">
			<a href="http://reddit.com/submit?url=http://beerpla.net/2009/04/08/perl-finding-files-the-fun-and-elegant-way/&amp;title=%5BPerl%5D+Finding+Files%2C+The+Fun+And+Elegant+Way" rel="nofollow" class="external" title="Share this on Reddit">Share this on Reddit</a>
		</li>
		<li class="shr-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://beerpla.net/2009/04/08/perl-finding-files-the-fun-and-elegant-way/&amp;title=%5BPerl%5D+Finding+Files%2C+The+Fun+And+Elegant+Way" rel="nofollow" class="external" title="Digg this!">Digg this!</a>
		</li>
		<li class="shr-delicious">
			<a href="http://delicious.com/post?url=http://beerpla.net/2009/04/08/perl-finding-files-the-fun-and-elegant-way/&amp;title=%5BPerl%5D+Finding+Files%2C+The+Fun+And+Elegant+Way" rel="nofollow" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="shr-stumbleupon">
			<a href="http://www.stumbleupon.com/submit?url=http://beerpla.net/2009/04/08/perl-finding-files-the-fun-and-elegant-way/&amp;title=%5BPerl%5D+Finding+Files%2C+The+Fun+And+Elegant+Way" rel="nofollow" class="external" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
		<li class="shr-mail">
			<a href="mailto:?subject=%22%5BPerl%5D%20Finding%20Files%2C%20The%20Fun%20And%20Elegant%20Way%22&amp;body=Link: http://beerpla.net/2009/04/08/perl-finding-files-the-fun-and-elegant-way/ (sent via shareaholic)%0D%0A%0D%0A----%0D%0A No%20matter%20what%20programming%20language%20you%20use%2C%20there%20comes%20a%20time%20when%20you%20need%20to%20search%20for%20a%20file%20somewhere%20on%20the%20file%20system.%20Here%2C%20I%20want%20to%20talk%20about%20accomplishing%20this%20task%20in%20Perl.%20There%20are%20many%20ways%20of%20doing%20so%2C%20most%20of%20them%20boring%2C%20but%20I%20want%20to%20discuss%20the%20fun%20and%20elegant%20way%20-%20using%20Fil" rel="nofollow" class="external" title="Email this to a friend?">Email this to a friend?</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>
Similar Posts:<ul><li><a href="http://beerpla.net/2009/03/05/perl-how-to-get-the-path-of-an-included-library-pm-regardless-of-current-directory/" rel="bookmark" title="March 5, 2009">[Perl] How To Get The Path Of An Included Library (.pm), Regardless Of Current Directory</a></li>
<li><a href="http://beerpla.net/2007/10/28/ftprush-cleanup-script/" rel="bookmark" title="October 28, 2007">FTPRush Cleanup Script</a></li>
<li><a href="http://beerpla.net/2008/03/21/quick-snippet-finding-if-a-file-has-a-media-extension-using-regex/" rel="bookmark" title="March 21, 2008">Quick Perl Snippet: Finding If A File Has A Media Extension Using Regex</a></li>
<li><a href="http://beerpla.net/2008/07/23/how-to-check-if-the-local-svn-revision-is-up-to-date/" rel="bookmark" title="July 23, 2008">How To Check If The Local SVN Revision Is Up-To-Date</a></li>
<li><a href="http://beerpla.net/2008/10/11/how-to-sort-folders-the-same-way-as-files-in-total-commander/" rel="bookmark" title="October 11, 2008">How To Sort Folders The Same Way As Files In Total Commander</a></li>
</ul><!-- Similar Posts took 6.801 ms --><p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save"><img src="http://beerpla.net/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a> </p>]]></content:encoded>
			<wfw:commentRss>http://beerpla.net/2009/04/08/perl-finding-files-the-fun-and-elegant-way/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>How To List Files Within tgz (tar.gz) Archives</title>
		<link>http://beerpla.net/2008/04/26/how-to-list-files-within-tgz-targz-archives/</link>
		<comments>http://beerpla.net/2008/04/26/how-to-list-files-within-tgz-targz-archives/#comments</comments>
		<pubDate>Sat, 26 Apr 2008 19:08:37 +0000</pubDate>
		<dc:creator>Artem Russakovskii</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[archive]]></category>
		<category><![CDATA[bzip]]></category>
		<category><![CDATA[file]]></category>
		<category><![CDATA[gunzip]]></category>
		<category><![CDATA[gz]]></category>
		<category><![CDATA[gzip]]></category>
		<category><![CDATA[list]]></category>
		<category><![CDATA[tar]]></category>
		<category><![CDATA[untar]]></category>
		<guid isPermaLink="false">http://beerpla.net/2008/04/26/how-to-list-files-within-tgz-targz-archives/</guid>
		<description><![CDATA[<p>This may not be very obvious but this is the command line to list files within a tar.gz archive on the fly:</p>
<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre>tar -tzf file.tar.gz</pre></td></tr></table></div>
<p>-t: lists files<br />-f: instructs tar to deal with the following filename (file.tar.gz)<br />-z: informs tar that the it&#039;s dealing with a gzip file (-j if it&#039;s bzip2)</p>
<div class="shr-bookmarks shr-bookmarks-expand">
<ul class="socials">
		<li class="shr-twitter">
			<a href="http://twitter.com/home?status=How+To+List+Files+Within+tgz+%28tar.gz%29+Archives+-+http://bit.ly/aSubhm&#38;source=shareaholic" rel="nofollow" class="external" title="Tweet This!">Tweet This!</a>
		</li>
		<li class="shr-facebook">
			<a href="http://www.facebook.com/share.php?v=4&#38;src=bm&#38;u=http://beerpla.net/2008/04/26/how-to-list-files-within-tgz-targz-archives/&#38;t=How+To+List+Files+Within+tgz+%28tar.gz%29+Archives" rel="nofollow" class="external" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="shr-googlebuzz">
			<a href="http://www.google.com/buzz/post?url=http://beerpla.net/2008/04/26/how-to-list-files-within-tgz-targz-archives/&#38;imageurl=" rel="nofollow" class="external" title="Post on Google Buzz">Post on Google Buzz</a>
		</li>
		<li class="shr-hackernews"></li></ul></div><p>...<div class=clear></div> <a href="http://beerpla.net/2008/04/26/how-to-list-files-within-tgz-targz-archives/" class="read_more"><div class=excerpt-end>Read the rest of this article &#187;</div></a></p>]]></description>
			<content:encoded><![CDATA[<p>This may not be very obvious but this is the command line to list files within a tar.gz archive on the fly:</p>
<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre>tar -tzf file.tar.gz</pre></td></tr></table></div>
<p>-t: lists files<br />-f: instructs tar to deal with the following filename (file.tar.gz)<br />-z: informs tar that the it&#039;s dealing with a gzip file (-j if it&#039;s bzip2)</p>
<div class="shr-bookmarks shr-bookmarks-expand">
<ul class="socials">
		<li class="shr-twitter">
			<a href="http://twitter.com/home?status=How+To+List+Files+Within+tgz+%28tar.gz%29+Archives+-+http://bit.ly/aSubhm&amp;source=shareaholic" rel="nofollow" class="external" title="Tweet This!">Tweet This!</a>
		</li>
		<li class="shr-facebook">
			<a href="http://www.facebook.com/share.php?v=4&amp;src=bm&amp;u=http://beerpla.net/2008/04/26/how-to-list-files-within-tgz-targz-archives/&amp;t=How+To+List+Files+Within+tgz+%28tar.gz%29+Archives" rel="nofollow" class="external" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="shr-googlebuzz">
			<a href="http://www.google.com/buzz/post?url=http://beerpla.net/2008/04/26/how-to-list-files-within-tgz-targz-archives/&amp;imageurl=" rel="nofollow" class="external" title="Post on Google Buzz">Post on Google Buzz</a>
		</li>
		<li class="shr-hackernews">
			<a href="http://news.ycombinator.com/submitlink?u=http://beerpla.net/2008/04/26/how-to-list-files-within-tgz-targz-archives/&amp;t=How+To+List+Files+Within+tgz+%28tar.gz%29+Archives" rel="nofollow" class="external" title="Submit this to Hacker News">Submit this to Hacker News</a>
		</li>
		<li class="shr-reddit">
			<a href="http://reddit.com/submit?url=http://beerpla.net/2008/04/26/how-to-list-files-within-tgz-targz-archives/&amp;title=How+To+List+Files+Within+tgz+%28tar.gz%29+Archives" rel="nofollow" class="external" title="Share this on Reddit">Share this on Reddit</a>
		</li>
		<li class="shr-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://beerpla.net/2008/04/26/how-to-list-files-within-tgz-targz-archives/&amp;title=How+To+List+Files+Within+tgz+%28tar.gz%29+Archives" rel="nofollow" class="external" title="Digg this!">Digg this!</a>
		</li>
		<li class="shr-delicious">
			<a href="http://delicious.com/post?url=http://beerpla.net/2008/04/26/how-to-list-files-within-tgz-targz-archives/&amp;title=How+To+List+Files+Within+tgz+%28tar.gz%29+Archives" rel="nofollow" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="shr-stumbleupon">
			<a href="http://www.stumbleupon.com/submit?url=http://beerpla.net/2008/04/26/how-to-list-files-within-tgz-targz-archives/&amp;title=How+To+List+Files+Within+tgz+%28tar.gz%29+Archives" rel="nofollow" class="external" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
		<li class="shr-mail">
			<a href="mailto:?subject=%22How%20To%20List%20Files%20Within%20tgz%20%28tar.gz%29%20Archives%22&amp;body=Link: http://beerpla.net/2008/04/26/how-to-list-files-within-tgz-targz-archives/ (sent via shareaholic)%0D%0A%0D%0A----%0D%0A This%20may%20not%20be%20very%20obvious%20but%20this%20is%20the%20command%20line%20to%20list%20files%20within%20a%20tar.gz%20archive%20on%20the%20fly%3Atar%20-tzf%20file.tar.gz%0A-t%3A%20lists%20files-f%3A%20instructs%20tar%20to%20deal%20with%20the%20following%20filename%20%28file.tar.gz%29-z%3A%20informs%20tar%20that%20the%20it%27s%20dealing%20with%20a%20gzip%20file%20%28-j%20if%20it%27s%20bzip2%29" rel="nofollow" class="external" title="Email this to a friend?">Email this to a friend?</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>
Similar Posts:<ul><li><a href="http://beerpla.net/2008/03/21/quick-snippet-finding-if-a-file-has-a-media-extension-using-regex/" rel="bookmark" title="March 21, 2008">Quick Perl Snippet: Finding If A File Has A Media Extension Using Regex</a></li>
<li><a href="http://beerpla.net/2008/04/09/some-useful-vim-commands-my-vim-cheatsheet/" rel="bookmark" title="April 9, 2008">Some Useful vim Commands &#8211; My vim Cheatsheet</a></li>
<li><a href="http://beerpla.net/2008/03/12/mass-renaming-directories-and-files-using-total-commander/" rel="bookmark" title="March 12, 2008">Mass Renaming Directories And Files Using Total Commander</a></li>
<li><a href="http://beerpla.net/2008/12/22/mastering-the-linux-shell-bash-shortcuts-explained/" rel="bookmark" title="December 22, 2008">Mastering The Linux Shell &#8211; Bash Shortcuts Explained (Now With Cheat Sheets)</a></li>
<li><a href="http://beerpla.net/2008/01/05/what-a-woman-says-what-she-really-means-what-a-man-says-what-he-really-means/" rel="bookmark" title="January 5, 2008">What A Woman Says, What She Really Means&#8230;   What A Man Says, What He Really Means…</a></li>
</ul><!-- Similar Posts took 8.369 ms --><p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save"><img src="http://beerpla.net/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a> </p>]]></content:encoded>
			<wfw:commentRss>http://beerpla.net/2008/04/26/how-to-list-files-within-tgz-targz-archives/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Quick Perl Snippet: Finding If A File Has A Media Extension Using Regex</title>
		<link>http://beerpla.net/2008/03/21/quick-snippet-finding-if-a-file-has-a-media-extension-using-regex/</link>
		<comments>http://beerpla.net/2008/03/21/quick-snippet-finding-if-a-file-has-a-media-extension-using-regex/#comments</comments>
		<pubDate>Fri, 21 Mar 2008 21:11:34 +0000</pubDate>
		<dc:creator>Artem Russakovskii</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[extension]]></category>
		<category><![CDATA[file]]></category>
		<category><![CDATA[media]]></category>
		<category><![CDATA[Perl]]></category>
		<category><![CDATA[regex]]></category>
		<category><![CDATA[regexp]]></category>
		<category><![CDATA[type]]></category>
		<category><![CDATA[url]]></category>
		<guid isPermaLink="false">http://beerpla.net/2008/03/21/quick-snippet-finding-if-a-file-has-a-media-extension-using-regex/</guid>
		<description><![CDATA[<p>Sometimes in my line of work, I need to figure out if a url or filename point to a media file by checking for the file extension. If it&#039;s a url, however, it may be followed by various parameters. Not to overcomplicate things, I came up with the following Perl code:</p>
<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
</pre></td><td class="code"><pre>#!/usr/bin/perl -w
use strict;
my $name = &#34;some_file.flv&#34;; # or http://example.com/file.mp4?foo=bar
my $is_media_type = ($name =~ /\.(wmv&#124;avi&#124;flv&#124;mov&#124;mkv&#124;mp..?&#124;swf&#124;ra.?&#124;rm&#124;as.&#124;m4[av]&#124;smi.?)\b/i);
if($is_media_type){
  print &#34;media extension found\n&#34;;
}
else{
  print &#34;not a media file\n&#34;;
}</pre></td></tr></table></div>
<p>This gets the job done without triggering any...<div class=clear></div> <a href="http://beerpla.net/2008/03/21/quick-snippet-finding-if-a-file-has-a-media-extension-using-regex/" class="read_more"><div class=excerpt-end>Read the rest of this article &#187;</div></a></p>]]></description>
			<content:encoded><![CDATA[<p>Sometimes in my line of work, I need to figure out if a url or filename point to a media file by checking for the file extension. If it&#039;s a url, however, it may be followed by various parameters. Not to overcomplicate things, I came up with the following Perl code:</p>
<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
</pre></td><td class="code"><pre>#!/usr/bin/perl -w
use strict;
my $name = &quot;some_file.flv&quot;; # or http://example.com/file.mp4?foo=bar
my $is_media_type = ($name =~ /\.(wmv|avi|flv|mov|mkv|mp..?|swf|ra.?|rm|as.|m4[av]|smi.?)\b/i);
if($is_media_type){
  print &quot;media extension found\n&quot;;
}
else{
  print &quot;not a media file\n&quot;;
}</pre></td></tr></table></div>
<p>This gets the job done without triggering any false positives (at least for the files/urls I&#039;ve been dealing with so far). Am I missing any obvious types? Do you have a better way to accomplish the same thing? If so, please share in the comments.</p>
<div class="shr-bookmarks shr-bookmarks-expand">
<ul class="socials">
		<li class="shr-twitter">
			<a href="http://twitter.com/home?status=Quick+Perl+Snippet%3A+Finding+If+A+File+Has+A+Media+Extension+Using+Regex+-+http://bit.ly/cMBVAD&amp;source=shareaholic" rel="nofollow" class="external" title="Tweet This!">Tweet This!</a>
		</li>
		<li class="shr-facebook">
			<a href="http://www.facebook.com/share.php?v=4&amp;src=bm&amp;u=http://beerpla.net/2008/03/21/quick-snippet-finding-if-a-file-has-a-media-extension-using-regex/&amp;t=Quick+Perl+Snippet%3A+Finding+If+A+File+Has+A+Media+Extension+Using+Regex" rel="nofollow" class="external" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="shr-googlebuzz">
			<a href="http://www.google.com/buzz/post?url=http://beerpla.net/2008/03/21/quick-snippet-finding-if-a-file-has-a-media-extension-using-regex/&amp;imageurl=" rel="nofollow" class="external" title="Post on Google Buzz">Post on Google Buzz</a>
		</li>
		<li class="shr-hackernews">
			<a href="http://news.ycombinator.com/submitlink?u=http://beerpla.net/2008/03/21/quick-snippet-finding-if-a-file-has-a-media-extension-using-regex/&amp;t=Quick+Perl+Snippet%3A+Finding+If+A+File+Has+A+Media+Extension+Using+Regex" rel="nofollow" class="external" title="Submit this to Hacker News">Submit this to Hacker News</a>
		</li>
		<li class="shr-reddit">
			<a href="http://reddit.com/submit?url=http://beerpla.net/2008/03/21/quick-snippet-finding-if-a-file-has-a-media-extension-using-regex/&amp;title=Quick+Perl+Snippet%3A+Finding+If+A+File+Has+A+Media+Extension+Using+Regex" rel="nofollow" class="external" title="Share this on Reddit">Share this on Reddit</a>
		</li>
		<li class="shr-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://beerpla.net/2008/03/21/quick-snippet-finding-if-a-file-has-a-media-extension-using-regex/&amp;title=Quick+Perl+Snippet%3A+Finding+If+A+File+Has+A+Media+Extension+Using+Regex" rel="nofollow" class="external" title="Digg this!">Digg this!</a>
		</li>
		<li class="shr-delicious">
			<a href="http://delicious.com/post?url=http://beerpla.net/2008/03/21/quick-snippet-finding-if-a-file-has-a-media-extension-using-regex/&amp;title=Quick+Perl+Snippet%3A+Finding+If+A+File+Has+A+Media+Extension+Using+Regex" rel="nofollow" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="shr-stumbleupon">
			<a href="http://www.stumbleupon.com/submit?url=http://beerpla.net/2008/03/21/quick-snippet-finding-if-a-file-has-a-media-extension-using-regex/&amp;title=Quick+Perl+Snippet%3A+Finding+If+A+File+Has+A+Media+Extension+Using+Regex" rel="nofollow" class="external" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
		<li class="shr-mail">
			<a href="mailto:?subject=%22Quick%20Perl%20Snippet%3A%20Finding%20If%20A%20File%20Has%20A%20Media%20Extension%20Using%20Regex%22&amp;body=Link: http://beerpla.net/2008/03/21/quick-snippet-finding-if-a-file-has-a-media-extension-using-regex/ (sent via shareaholic)%0D%0A%0D%0A----%0D%0A Sometimes%20in%20my%20line%20of%20work%2C%20I%20need%20to%20figure%20out%20if%20a%20url%20or%20filename%20point%20to%20a%20media%20file%20by%20checking%20for%20the%20file%20extension.%20If%20it%27s%20a%20url%2C%20however%2C%20it%20may%20be%20followed%20by%20various%20parameters.%20Not%20to%20overcomplicate%20things%2C%20I%20came%20up%20with%20the%20following%20Perl%20code%3A%0A%0A%23%21%2Fusr%2Fbin%2Fperl%20-w%0Ause%20strict%3B%0Amy" rel="nofollow" class="external" title="Email this to a friend?">Email this to a friend?</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>
Similar Posts:<ul><li><a href="http://beerpla.net/2009/04/08/perl-finding-files-the-fun-and-elegant-way/" rel="bookmark" title="April 8, 2009">[Perl] Finding Files, The Fun And Elegant Way</a></li>
<li><a href="http://beerpla.net/2007/08/04/watch-a-useful-linux-command-you-may-have-never-heard-of/" rel="bookmark" title="August 4, 2007">Watch &#8211; A Useful Linux Command You May Have Never Heard Of</a></li>
<li><a href="http://beerpla.net/2009/03/17/twitter-autocomplete-auto-url-expansion-auto-url-shortener-auto-pagination-rt-button-nested-replies-inline-media-embed-search-tabs-and-more/" rel="bookmark" title="March 17, 2009">Twitter.com Autocomplete, Auto URL Expansion, Auto URL Shortener, RT Button, Nested Replies, Inline Media Embed, Search Tabs, And More</a></li>
<li><a href="http://beerpla.net/2008/04/26/how-to-list-files-within-tgz-targz-archives/" rel="bookmark" title="April 26, 2008">How To List Files Within tgz (tar.gz) Archives</a></li>
<li><a href="http://beerpla.net/2010/01/13/wordpress-plugin-development-how-to-include-css-and-javascript-conditionally-and-only-when-needed-by-the-posts/" rel="bookmark" title="January 13, 2010">[WordPress Plugin Development] How To Include CSS and JavaScript Conditionally And Only When Needed By The Posts</a></li>
</ul><!-- Similar Posts took 13.448 ms --><p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save"><img src="http://beerpla.net/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a> </p>]]></content:encoded>
			<wfw:commentRss>http://beerpla.net/2008/03/21/quick-snippet-finding-if-a-file-has-a-media-extension-using-regex/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
