<?xml version="1.0" encoding="windows-1252"?>
<node id="906563" title="Stoney2005's scratchpad" created="2011-05-24 16:05:28" updated="2011-05-24 16:05:28">
<type id="182711">
scratchpad</type>
<author id="906562">
Stoney2005</author>
<data>
<field name="doctext">
&lt;code&gt;s/(\b)([a-z])/$1\u$2/g; # Convert to title case&lt;/code&gt;
&lt;code&gt;sub doLock {
	use Fcntl ':flock'; # import LOCK_* constants 
	my($flag) = @_;
	if($flag) {
	if ((open(LOCK, "&gt;&gt; $0.pid") || open(LOCK, "&gt;&gt; $0.pid")) &amp;&amp; !flock(LOCK, LOCK_EX|LOCK_NB)) {print "FAILED TO GET LOCK\nError: $!\nFile: $0.pid\n"; exit()}
	return();
	}
	flock(LOCK, LOCK_UN); close(LOCK);
} # doLock(0) or doLock(1)&lt;/code&gt;
&lt;code&gt;sub RandomAlpha {
my($digits)=@_;
my($alpha);
while($digits){
$alpha.=((A..Z)[int(rand()*26]));
$digits--
};
return($alpha)
} # RandomAlpha(5) returns 5 random alpha chars&lt;/code&gt;
&lt;code&gt;sub RandomAlpha {
my($count,$digits)=@_;
my($counter,$alpha,@array);
while($count){
$counter=$digits;
while($counter){
$alpha.=(A..Z)[int(rand()*26)];
$counter--;
};
push(@array,$alpha);
$alpha="";
$count--;
};
return(@array);
} 
# @array = RandomAlpha(5,12);
# foreach $value @array {print "$value\n"}
&lt;/code&gt;
&lt;code&gt;use Mail::Sendmail;
%mail = ( To      =&gt; 'email',
From    =&gt; 'from',
Subjest =&gt; 'Testing',
Message =&gt; "Testing the Mail::Sendmail"
);
sendmail(%mail) or die $Mail::Sendmail::error;&lt;/code&gt;</field>
</data>
</node>
