<?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>eTechTips &#187; Perl</title>
	<atom:link href="http://www.etechtips.com/articles/programming/perl/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.etechtips.com</link>
	<description>Your Technical resource</description>
	<lastBuildDate>Wed, 01 Feb 2012 21:38:57 +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: Format date strings</title>
		<link>http://www.etechtips.com/2011/12/07/perl-format-date-strings/</link>
		<comments>http://www.etechtips.com/2011/12/07/perl-format-date-strings/#comments</comments>
		<pubDate>Wed, 07 Dec 2011 19:48:57 +0000</pubDate>
		<dc:creator>ecdown</dc:creator>
				<category><![CDATA[Perl]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Scripting]]></category>
		<category><![CDATA[Utilities]]></category>
		<category><![CDATA[perl]]></category>
		<category><![CDATA[scripting]]></category>

		<guid isPermaLink="false">http://www.etechtips.com/?p=586</guid>
		<description><![CDATA[The other day I had a requirement to fill in a date value while creating an entity in ClearQuest. The field that was required was a date and was formatted as &#8220;mm/dd/yyyy hh:MM::SS AM&#124;PM&#8221;. I used the localtime function to return the date and used sprintf to format the date to the proper output. The [...]]]></description>
			<content:encoded><![CDATA[<p>The other day I had a requirement to fill in a date value while creating an entity in ClearQuest.  The field that was required was a date and was formatted as &#8220;mm/dd/yyyy hh:MM::SS AM|PM&#8221;.  I used the localtime function to return the date and used sprintf to format the date to the proper output.<br />
The reason I used sprintf was that for hours, months and days less 10 the output was 1 digit instead of two and the input was not allowed.  The %02d states that the digits used will be a minumum of 2 in this case.</p>
<p>Here is the sample program I wrote to test the expected output:</p>
<pre>
 my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime;

# formatted just by concatenating output
my $datestring = $mon . "/" . $mday . "/" . $year . "  " . $hour . ":" . $min.
":" . $sec  ;

# formatted using sprintf to ensure proper digit counts are output
my $datestring2 = sprintf("%02d/%02d/%04d %d:%02d:%02d %s",$mon,$mday,1900 +$yea
r,$hour,$min,$sec, $hour >= 12? "PM" : "AM");

 print $datestring;
  print $datestring2;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.etechtips.com/2011/12/07/perl-format-date-strings/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Perl: Open and read file line by line</title>
		<link>http://www.etechtips.com/2011/09/28/perl-open-and-read-file-line-by-line/</link>
		<comments>http://www.etechtips.com/2011/09/28/perl-open-and-read-file-line-by-line/#comments</comments>
		<pubDate>Wed, 28 Sep 2011 16:29:42 +0000</pubDate>
		<dc:creator>ecdown</dc:creator>
				<category><![CDATA[Perl]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Scripting]]></category>
		<category><![CDATA[Utilities]]></category>
		<category><![CDATA[perl]]></category>
		<category><![CDATA[scripting]]></category>

		<guid isPermaLink="false">http://www.etechtips.com/?p=459</guid>
		<description><![CDATA[I regularly have to process Comma Seperated Value or CSV files, usually for user lists. So the following perl code is a framework for processing a file line by line. #!/usr/bin/perl use strict; my $line; open(FILEIN, "filename.txt"); while(&#60;FILEIN&#62;) { chomp(); $line = $_; # Process $line for data # Example seperating line by commas: my [...]]]></description>
			<content:encoded><![CDATA[<p>I regularly have to process Comma Seperated Value or CSV files, usually for user lists.  So the following perl code is a framework for processing a file line by line.</p>
<pre>
#!/usr/bin/perl
use strict;
my $line;

open(FILEIN, "filename.txt");

while(&lt;FILEIN&gt;)
{
  chomp();
  $line = $_;
  # Process $line for data
  # Example seperating line by commas:
  my ($username,$firstname,$lastname,$email) = split(/,/,$line);
}

close(FILEIN);
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.etechtips.com/2011/09/28/perl-open-and-read-file-line-by-line/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Perl: Hashes</title>
		<link>http://www.etechtips.com/2011/09/07/perl-hashes/</link>
		<comments>http://www.etechtips.com/2011/09/07/perl-hashes/#comments</comments>
		<pubDate>Wed, 07 Sep 2011 13:00:16 +0000</pubDate>
		<dc:creator>ecdown</dc:creator>
				<category><![CDATA[Perl]]></category>
		<category><![CDATA[Scripting]]></category>
		<category><![CDATA[Utilities]]></category>
		<category><![CDATA[hash]]></category>
		<category><![CDATA[perl]]></category>
		<category><![CDATA[scripting]]></category>

		<guid isPermaLink="false">http://www.etechtips.com/?p=295</guid>
		<description><![CDATA[Here are some basics about Perl hashes that can be helpful to be used when an you need to associate a label with some value such as for names and telephone numbers or account numbers with amounts owed. Create a hash variable. my %hashvar; Create a hash reference my $refhash = {}; Add a value [...]]]></description>
			<content:encoded><![CDATA[<p>Here are some basics about Perl hashes that can be helpful to be used when an you need to associate a label with some value such as for names and telephone numbers or account numbers with amounts owed.</p>
<p>Create a hash variable.</p>
<pre>
my %hashvar;
</pre>
<p>Create a hash reference </p>
<pre>
my $refhash = {};
</pre>
<p>Add a value to a hash variable.</p>
<pre>
$hashvar{'somekey'} = 'someval';
</pre>
<p>Add a value to a hash reference.</p>
<pre>
$hashref->{'somekey'} = 'someotherval';
</pre>
<p>Access a value in a hash.</p>
<pre>
print $hashvar{'somekey'};
</pre>
<p>Access a value in a hash reference.</p>
<pre>
print $hashref->{'somekey}';
</pre>
<p>Access all Keys in a hash variable.<br />
foreach my $k (keys(%hashvar))<br />
{<br />
   print $hashvar{$k};<br />
}
</pre>
<p>Access all Keys in a hash reference.</p>
<pre>
foreach my $k (keys(%$hashref))
{
  print $k . "\n";
}
</pre>
<p>Access all Keys and values in a hash.</p>
<pre>
while (my ($key,$value) = each %hashvar)
{
  print "Key: " . $key . " has value:" . $value . "\n";
}
</pre>
<p>Access all Keys and values in a hash.</p>
<pre>
while (my ($key,$value) = each %$refhash)
{
  print "Key: " . $key . " has value:" . $value . "\n";
}
</pre>
<p>Assigning multiple values to a hash</p>
<pre>
%hasvar = (
  'test2' => 'myval',
  'test3' => 'myval3'
);
</pre>
<p>Note: This will clear the existing hash.</p>
<p>Delete a value from a hash</p>
<pre>
delete $hashvar{'key1'};
</pre>
<p>Delete a value from a hash reference.</p>
<pre>
delete $hashref->{'key1'};
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.etechtips.com/2011/09/07/perl-hashes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Perl: Arrays</title>
		<link>http://www.etechtips.com/2011/09/03/perl-arrays/</link>
		<comments>http://www.etechtips.com/2011/09/03/perl-arrays/#comments</comments>
		<pubDate>Sat, 03 Sep 2011 13:20:55 +0000</pubDate>
		<dc:creator>ecdown</dc:creator>
				<category><![CDATA[Perl]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Scripting]]></category>
		<category><![CDATA[array]]></category>
		<category><![CDATA[perl]]></category>
		<category><![CDATA[scripting]]></category>

		<guid isPermaLink="false">http://www.etechtips.com/?p=437</guid>
		<description><![CDATA[I use perl arrays in some of my programs, and just started to look at the regular things that I do with these arrays and thought it would be useful to keep a list of frequently used items. Create a variable specified as an array. my @vararray Add an item to the beginning of an [...]]]></description>
			<content:encoded><![CDATA[<p>I use perl arrays in some of my programs, and just started to look at the regular things that I do with these arrays and thought it would be useful to keep a list of frequently used items.</p>
<p>Create a variable specified as an array.</p>
<pre>
my @vararray
</pre>
<p>Add an item to the beginning of an array</p>
<pre>
unshift (@vararray, "File2");
</pre>
<p>Add an item to the end of an array</p>
<pre>
push (@vararray, "File1");
</pre>
<p>Remove an item from the beginning of an array</p>
<pre>
my $var = shift(@array);
</pre>
<p>Remove an item from the end of an array</p>
<pre>
pop(@array)
</pre>
<p>Clear an array </p>
<pre>
@vararray = ();
</pre>
<p>Address an item in an array</p>
<pre>
print $vararray[0] ;
</pre>
<p>Get the size of an array</p>
<pre>
my $arraysize = @array;
</pre>
<p>Remove an item based on the index</p>
<pre>
delete @vararray[1];
</pre>
<p>Iterate over an array</p>
<pre>
foreach my $var (@vararay)
{
  print "$var \n";
}

# or
my $size = @vararray;
my $i;
for ($i = 0 ; $i < @size; $i++)
{
  print "$vararray[$i]\n";
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.etechtips.com/2011/09/03/perl-arrays/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to add library paths to perl</title>
		<link>http://www.etechtips.com/2011/08/13/how-to-add-library-paths-to-perl/</link>
		<comments>http://www.etechtips.com/2011/08/13/how-to-add-library-paths-to-perl/#comments</comments>
		<pubDate>Sat, 13 Aug 2011 15:32:50 +0000</pubDate>
		<dc:creator>ecdown</dc:creator>
				<category><![CDATA[Perl]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Scripting]]></category>
		<category><![CDATA[perl]]></category>
		<category><![CDATA[scripting]]></category>

		<guid isPermaLink="false">http://www.etechtips.com/?p=194</guid>
		<description><![CDATA[I need to write custom Perl libraries sometimes and an easy method to make sure that they are found on the path is to use the PERL5LIB environment variable. So either set it in your current environment or in a shell you can just specify the contents before you run your script. PERL5LIB=/PATH/WHERE/LIB/IS perl scripttorun.pl]]></description>
			<content:encoded><![CDATA[<p>I need to write custom Perl libraries sometimes and an easy method to make sure that they are found on the path is to use the PERL5LIB environment variable.</p>
<p>So either set it in your current environment or in a shell you can just specify the contents before you run your script.</p>
<pre>PERL5LIB=/PATH/WHERE/LIB/IS perl scripttorun.pl </pre>
]]></content:encoded>
			<wfw:commentRss>http://www.etechtips.com/2011/08/13/how-to-add-library-paths-to-perl/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Perl: CPAN installing modules</title>
		<link>http://www.etechtips.com/2011/08/05/perl-cpan-installing-modules/</link>
		<comments>http://www.etechtips.com/2011/08/05/perl-cpan-installing-modules/#comments</comments>
		<pubDate>Fri, 05 Aug 2011 14:00:42 +0000</pubDate>
		<dc:creator>ecdown</dc:creator>
				<category><![CDATA[Perl]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Scripting]]></category>
		<category><![CDATA[perl]]></category>
		<category><![CDATA[scripting]]></category>

		<guid isPermaLink="false">http://www.etechtips.com/?p=338</guid>
		<description><![CDATA[Sometimes it is necessary to install other modules into the Perl environment. Luckily there is a great repository of modules known as CPAN (The Comprehensive Perl Archive Network). This lets you install modules to help with encryption, XML,YAML, and many other things. There are a few ways to install a package and here are the [...]]]></description>
			<content:encoded><![CDATA[<p>Sometimes it is necessary to install other modules into the Perl environment.  Luckily there is a great repository of modules known as CPAN (The Comprehensive Perl Archive Network). This lets you install modules to help with encryption, XML,YAML, and many other things.  There are a few ways to install a package and here are the ones that I use the most.</p>
<p>Using the CPAN shell:</p>
<pre>perl -MCPAN -e shell</pre>
<p>This will open a command prompt that will let you search for CPAN modules with:</p>
<pre>i /PACKAGENAME/</pre>
<p>or install a new module:</p>
<pre>install /DateTime/</pre>
<p>The nice thing about installing with CPAN is that it will look for the dependencies and suggest installing them before the module you requested.</p>
<p><em>NOTE:</em>This can take some time and your dependencies could have dependencies.</p>
<p>The other method I use is to skip the CPAN prompt and just directly execute the install of the module:</p>
<pre>perl -MCPAN -e 'install DateTime'</pre>
<p>This is just the most basic of usage, and there is probably a lot more you can do, but I have not had to use much more than this.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.etechtips.com/2011/08/05/perl-cpan-installing-modules/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Gallery of Hello World!</title>
		<link>http://www.etechtips.com/2011/08/04/gallery-of-hello-world/</link>
		<comments>http://www.etechtips.com/2011/08/04/gallery-of-hello-world/#comments</comments>
		<pubDate>Thu, 04 Aug 2011 15:14:39 +0000</pubDate>
		<dc:creator>ecdown</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[C/C++]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Perl]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Shell]]></category>
		<category><![CDATA[perl]]></category>

		<guid isPermaLink="false">http://www.etechtips.com/?p=324</guid>
		<description><![CDATA[Here is a list of the Hello World Programs for different languages: C #include int main() { printf("Hello World!"); } C++ #include int main() { cout &#60;&#60; "Hello World!" &#60;&#60; endl; } C# public class HelloWorld public static void Main() { System.Console.WriteLine("Hello World!"); } Java class HelloWorld { static void main(String[] args) { System.out.println("Hello World!"); [...]]]></description>
			<content:encoded><![CDATA[<p>Here is a list of the Hello World Programs for different languages:</p>
<p>C</p>
<pre>#include
int main()
{
printf("Hello World!");
}</pre>
<p>C++</p>
<pre>#include
int main()
{
cout &lt;&lt; "Hello World!" &lt;&lt; endl;
}</pre>
<p>C#</p>
<pre>public class HelloWorld
  public static void Main()
  {
    System.Console.WriteLine("Hello World!");
  }</pre>
<p>Java</p>
<pre>class HelloWorld {
static void main(String[] args)
{
System.out.println("Hello World!");
}</pre>
<p>SHELL</p>
<pre>echo "Hello World"</pre>
<p>Python</p>
<pre>print "Hello World!\n"</pre>
<p>Ruby</p>
<pre>puts "Hello World!"</pre>
<p>Perl</p>
<pre>print "Hello World!\n";</pre>
<p>PHP</p>
<pre>  &lt;?php
    print "Hello World!";
  ?&gt;</pre>
<p>This is the simplest form of Hello World for most of these languages.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.etechtips.com/2011/08/04/gallery-of-hello-world/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Testing perl modules</title>
		<link>http://www.etechtips.com/2011/01/05/testing-perl-modules/</link>
		<comments>http://www.etechtips.com/2011/01/05/testing-perl-modules/#comments</comments>
		<pubDate>Wed, 05 Jan 2011 22:20:20 +0000</pubDate>
		<dc:creator>ecdown</dc:creator>
				<category><![CDATA[Perl]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Scripting]]></category>

		<guid isPermaLink="false">http://www.etechtips.com/?p=185</guid>
		<description><![CDATA[A quick way to test a perl module with a new method is to use a command like the following: $ perl -MeTechTips::IssueTracking::ClearQuest -we '$tr = eTechtips::IssueTracking::ClearQuest->new();' This will test the new and ensure that you have the correct syntax if you do not have an easy test environment for your code, for example as [...]]]></description>
			<content:encoded><![CDATA[<p>A quick way to test a perl module with a new method is to use a command like the following:</p>
<pre>
$ perl -MeTechTips::IssueTracking::ClearQuest -we '$tr =  eTechtips::IssueTracking::ClearQuest->new();'
</pre>
<p>This will test the new and ensure that you have the correct syntax if you do not have an easy test environment for your code, for example as I do not have a ClearQuest instance to test with.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.etechtips.com/2011/01/05/testing-perl-modules/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Perl find location of a library</title>
		<link>http://www.etechtips.com/2010/12/24/perl-find-location-of-a-library/</link>
		<comments>http://www.etechtips.com/2010/12/24/perl-find-location-of-a-library/#comments</comments>
		<pubDate>Fri, 24 Dec 2010 05:59:45 +0000</pubDate>
		<dc:creator>ecdown</dc:creator>
				<category><![CDATA[Perl]]></category>

		<guid isPermaLink="false">http://www.etechtips.com/?p=206</guid>
		<description><![CDATA[If you are not sure of the location of where a library is being included from in Perl you can use the following command: perl -MXML::SAX -le 'print $INC{"XML/SAX.pm"}' This search is for the XML::SAX library and it displays the location of the SAX.pm file.]]></description>
			<content:encoded><![CDATA[<p>If you are not sure of the location of where a library is being included from in Perl you can use the following command:</p>
<pre>
perl -MXML::SAX -le 'print $INC{"XML/SAX.pm"}'
</pre>
<p>This search is for the XML::SAX library and it displays the location of the SAX.pm file.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.etechtips.com/2010/12/24/perl-find-location-of-a-library/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Perl: Missing ParserDetails.ini</title>
		<link>http://www.etechtips.com/2010/12/24/perl-missing-parserdetails-ini/</link>
		<comments>http://www.etechtips.com/2010/12/24/perl-missing-parserdetails-ini/#comments</comments>
		<pubDate>Fri, 24 Dec 2010 05:31:13 +0000</pubDate>
		<dc:creator>ecdown</dc:creator>
				<category><![CDATA[Perl]]></category>
		<category><![CDATA[Scripting]]></category>
		<category><![CDATA[perl]]></category>
		<category><![CDATA[scripting]]></category>

		<guid isPermaLink="false">http://www.etechtips.com/?p=201</guid>
		<description><![CDATA[I have some scripts that were giving me the following message: could not find ParserDetails.ini in /usr/lib/perl5/vendor_perl/5.10/XML/SAX The way that I worked around this message was to create the ParserDetails.ini file in the /usr/lib/perl5/vendor_perl/5.10/XML/SAX directory with the following contents. [XML::SAX::PurePerl] http://xml.org/sax/features/namespaces = 1]]></description>
			<content:encoded><![CDATA[<p>I have some scripts that were giving me the following message:<br />
could not find ParserDetails.ini in /usr/lib/perl5/vendor_perl/5.10/XML/SAX</p>
<p>The way that I worked around this message was to create the ParserDetails.ini file in the /usr/lib/perl5/vendor_perl/5.10/XML/SAX directory with the following contents.</p>
<pre>
[XML::SAX::PurePerl]
http://xml.org/sax/features/namespaces = 1
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.etechtips.com/2010/12/24/perl-missing-parserdetails-ini/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

