<?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>Thronic.com &#187; Perl</title>
	<atom:link href="http://thronic.com/category/development/perl/feed/" rel="self" type="application/rss+xml" />
	<link>http://thronic.com</link>
	<description>Personal Computing and Development by Dag J. Nedrelid</description>
	<lastBuildDate>Wed, 28 Apr 2010 12:21:44 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>User storage report in Linux</title>
		<link>http://thronic.com/2007/computing/user-storage-report-in-linux/</link>
		<comments>http://thronic.com/2007/computing/user-storage-report-in-linux/#comments</comments>
		<pubDate>Tue, 18 Dec 2007 12:18:51 +0000</pubDate>
		<dc:creator>Dag Jonny Nedrelid</dc:creator>
				<category><![CDATA[Computing]]></category>
		<category><![CDATA[Perl]]></category>

		<guid isPermaLink="false">http://thronic.com/?p=93</guid>
		<description><![CDATA[A way to see how much space your linux user accounts takes up.

-
Here is my way of doing it with Perl.

#!/usr/bin/perl

printf "Generating overview over user account storage amounts..\n\n";

opendir(DIR, '/home/');
@dirs = readdir(DIR);
closedir(DIR);

foreach $dir (@dirs) {
if($dir ne '..' &#38;&#38; $dir ne '.') {
$dir_size = `du -h --max-depth=0 /home/$dir`;
$dir_size =~ s/\s.*//;
printf "$dir : $dir_size";
}
}

printf "\n";

Put code in a [...]]]></description>
			<content:encoded><![CDATA[<p><strong>A way to see how much space your linux user accounts takes up.</strong></p>
<p><span id="more-93"></span></p>
<p style="color: #ffffff;">-</p>
<p style="font-weight: bold;">Here is my way of doing it with Perl.</p>
<blockquote>
<pre><code>#!/usr/bin/perl

printf "Generating overview over user account storage amounts..\n\n";

opendir(DIR, '/home/');
@dirs = readdir(DIR);
closedir(DIR);

foreach $dir (@dirs) {
<span style="padding-left:10px">if($dir ne '..' &amp;&amp; $dir ne '.') {</span>
<span style="padding-left:20px">$dir_size = `du -h --max-depth=0 /home/$dir`;</span>
<span style="padding-left:20px">$dir_size =~ s/\s.*//;</span>
<span style="padding-left:20px">printf "$dir : $dir_size";</span>
<span style="padding-left:10px">}</span>
}

printf "\n";</code></pre>
</blockquote>
<p>Put code in a file and chmod 755 to it to run as either console command or through a website.</p>
<p style="font-weight: bold;">To show through a website you can use something like this.</p>
<blockquote><p><code>#!/usr/bin/perl<br />
$output = `cat /home/myuser/scripts/thescript.pl`;<br />
print "Content-Type: text/html\n\n";<br />
print '&lt;pre&gt;'. $output .'&lt;/pre&gt;';<br />
</code></p></blockquote>
<p style="font-weight: bold;">Here is how the output looks like</p>
<blockquote><p>root@Mybox adminscripts # ./userstorage<br />
Generating overview over user account storage amounts..</p>
<p>User1 : 608K<br />
User2 : 28M<br />
User4 : 300M<br />
MyUser : 400K</p>
<p>root@Mybox adminscripts #</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://thronic.com/2007/computing/user-storage-report-in-linux/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>GET and POST for Perl</title>
		<link>http://thronic.com/2007/development/get-and-post-for-perl/</link>
		<comments>http://thronic.com/2007/development/get-and-post-for-perl/#comments</comments>
		<pubDate>Sun, 09 Dec 2007 12:43:09 +0000</pubDate>
		<dc:creator>Dag Jonny Nedrelid</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Perl]]></category>

		<guid isPermaLink="false">http://thronic.com/?p=101</guid>
		<description><![CDATA[This is a Perl script I wrote a while back for collecting GET and POST variables. Made to run on Win32. Change the top line for Perl parser if used in Linux. The script was originally for putting all the variables into 1 single array, this version divides the GET and POST variables into 2 [...]]]></description>
			<content:encoded><![CDATA[<p><strong>This is a Perl script I wrote a while back for collecting GET and POST variables. Made to run on Win32. Change the top line for Perl parser if used in Linux. The script was originally for putting all the variables into 1 single array, this version divides the GET and POST variables into 2 arrays, queryGET[] and queryFORM[]. It&#8217;s scripted for being included in a main script, hence the return(1).</strong></p>
<p><span id="more-101"></span></p>
<blockquote>
<pre><code>#!c:/perl/bin/perl.exe
#QueryString Parser
#By DJ Nedrelid.
use CGI;
$query = new CGI;

<strong>#GET variables</strong>
@values = split(/&amp;/,$ENV{'QUERY_STRING'});
foreach $i (@values) {
  ($varname, $mydata) = split(/=/,$i);
  $queryGET{$varname} = $mydata;
}

<strong>#POST variables</strong>
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
@pairs = split(/&amp;/, $buffer);
foreach $pair (@pairs) {
  ($name, $value) = split(/=/, $pair);
  $value =~ tr/+/ /;
  $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
  $queryFORM{$name} = $value;
}

<strong>#ENCTYPE variables</strong>
foreach $key (sort {$a &lt;=&gt; $b} $query-&gt;param()) {
  next if ($key =~ /^\s*$/);
  next if ($query-&gt;param($key) =~ /^\s*$/);
  if ($key !~ /^file-to-upload-(\d+)$/) {
   $queryFORM{$key} = $query-&gt;param($key);
   next;
  }
}

return(1); </code></pre>
</blockquote>
]]></content:encoded>
			<wfw:commentRss>http://thronic.com/2007/development/get-and-post-for-perl/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
