<p>As usual the rule is <b>Don't be right - be smart.</b>. When someone criticises you (and may be an op), you should: 1. Ask them what they mean. 2. Agree and empathise with them, 3. Try to negotiate a common ground. Don't try to be defensive-aggressive and try to prove the other side's wrong because that will only make them more angry at you.

-</p><p>Naturally, this applies primarily to personal criticisms or those that influence one's behaviour in the channel. If you're having a "colour of the bikeshed" argument (i.e "Subversion vs. git vs. bzr vs. hg vs....") or a discussion about whether <tt>$self-&gt;method(%args)</tt> is better than <tt>$self-&gt;method({%args})</tt>, a silly off-topic discussion about whether <a href="http://www.shlomifish.org/humour/bits/facts/Chuck-Norris/" class='external text' title="http://www.shlomifish.org/humour/bits/facts/Chuck-Norris/" rel="nofollow">Chuck Norris</a> can beat Superman or Batman or not, or something like that, then probably much less is at stake there.

+</p><p>Naturally, this applies primarily to personal criticisms or those that influence one's behaviour in the channel. If you're having a "colour of the bikeshed" argument (i.e "Subversion vs. git vs. bzr vs. hg vs....") or a discussion about whether <tt>$self-&gt;method(%args)</tt> is better than <tt>$self-&gt;method({%args})</tt>, a silly off-topic discussion about whether <a href="http://www.shlomifish.org/humour/bits/facts/Chuck-Norris/" class='external text' title="http://www.shlomifish.org/humour/bits/facts/Chuck-Norris/">Chuck Norris</a> can beat Superman or Batman or not, or something like that, then probably much less is at stake there.

<p>Not all of the people on #perl are native English speakers. We also welcome people of all nationalities and native languages, even if their English is not perfect. However, we expect people to try to improve their written English in time, and learn from their mistakes. Improving your mastery of English will not only make it easier for you to communicate, but will also give you access to more high-quality material about Perl and programming in general (written either by native or non-native English speakers); allow you to better comment, document and communicate about your code; and finally, it will improve your skills as a programmer, because there is a general belief that people who speak and write human languages well, write better, more elegant and more idiomatic code.

</p><p>It's OK to have bad English, but you should try to improve it, because many native and non-native speakers (especially many geeks who are less capable of understanding the meaning of badly phrased sentences) will have a hard time understanding you.

-</p><p>In addition to that, we should note that you should be tolerable of other people's not-so-idiomatic or possibly may-be-considered-derogatory English because they may speak, and think in a slightly different language than in English. For examples, in some languages there are non-derogatory words for a "female guy", whereas in English "girl" and "gal" are somewhat derogatory. As a result, a non-native English speaker may use them this way. (See for example what <a href="http://shlomif.livejournal.com/55146.html" class='external text' title="http://shlomif.livejournal.com/55146.html" rel="nofollow">Shlomi Fish (rindolf) wrote about Hebrew words to describe humans</a>).

+</p><p>In addition to that, we should note that you should be tolerable of other people's not-so-idiomatic or possibly may-be-considered-derogatory English because they may speak, and think in a slightly different language than in English. For examples, in some languages there are non-derogatory words for a "female guy", whereas in English "girl" and "gal" are somewhat derogatory. As a result, a non-native English speaker may use them this way. (See for example what <a href="http://shlomif.livejournal.com/55146.html" class='external text' title="http://shlomif.livejournal.com/55146.html">Shlomi Fish (rindolf) wrote about Hebrew words to describe humans</a>).

</p><p>Moreover, in some languages it is more natural to say "a guy from work", "a girl from work" than "my co-worker", and most Indo-European and Semitic languages have compulsory genders, including for inanimate objects, so it's natural for their English to be not-so-idiomatic.

</p><p>Finally, some foreign or non-foreign people may try to emulate some American, British, Australian, etc. culture, which they see on Television, movies, etc. and while this may seem silly at times, should also be tolerated.

</p><p>So don't be too strict about which language is being said.

<div class="editsection" style="float:right;margin-left:5px;">[<a href="http://perl.net.au/wiki/?title=Freenode_Sharp_Perl_FAQ&action=edit&section=6" title="Edit section: What do I need to do to get a good answer to my question?">edit</a>]</div><a name="What_do_I_need_to_do_to_get_a_good_answer_to_my_question.3F"></a><h3> What do I need to do to get a good answer to my question? </h3>

<p>If you ask a bad question, you'll often get a bad answer, or no answer at all. As the questioner you probably won't realise that you are stating your question badly. When asking a question try to focus on the underlying task or goal, not the method you are currently trying.

</p><p>Try to step away from the problem you're working with and see if you can trim your data set to about 5 lines and your code to less than 10 and still demonstrate the problem. We don't want to understand how your whole application works just in order to understand your question.

-</p><p>Please paste the code that reproduces the problem to one of the channel's pastebots, such as <a href="http://erxz.com/pb/" class='external free' title="http://erxz.com/pb/" rel="nofollow">http://erxz.com/pb/</a> . Paste the entire program, not selected parts of it and make sure you make your intentions clear. If the program is too long or is confidential, try to reduce it into a smaller testcase that still reproduces your problem.

+</p><p>Please paste the code that reproduces the problem to one of the channel's pastebots, such as <a href="http://erxz.com/pb/" class='external free' title="http://erxz.com/pb/">http://erxz.com/pb/</a> . Paste the entire program, not selected parts of it and make sure you make your intentions clear. If the program is too long or is confidential, try to reduce it into a smaller testcase that still reproduces your problem.

</p><p>Show us that you've put some effort into finding the answer yourself, or at least writing the question down well. This is much more likely to be rewarded by us giving you some of our time to help you fix whatever your problem is. Read the following resources for hints on how to ask questions that encourage answers. These techniques work on IRC channels, mailing lists and online forums.

<div class="editsection" style="float:right;margin-left:5px;">[<a href="http://perl.net.au/wiki/?title=Freenode_Sharp_Perl_FAQ&action=edit&section=7" title="Edit section: What is Considered On-Topic?">edit</a>]</div><a name="What_is_Considered_On-Topic.3F"></a><h3> What is Considered On-Topic? </h3>

<p>One thing to note that is as opposed to some programming language channels on Freenode that limit themselves to the core language (which is sometimes fully specified in a standard), we not only have a problem in discussing non-core code, but even encourage you to use many high-quality, recommended, yet non-core, modules from <a href="http://perl.net.au/wiki/CPAN" title="CPAN">CPAN</a> - the Comprehensive Perl Archive Network. To quote Audrey Tang had said "UNIX is my IDE, perl 5 is my VM, CPAN is my language.".

-</p><p>Please read what <a href="http://www.shadowcat.co.uk/blog/matt-s-trout/but-i-cant-use-cpan/" class='external text' title="http://www.shadowcat.co.uk/blog/matt-s-trout/but-i-cant-use-cpan/" rel="nofollow">Matt Trout (mst) wrote about "But I can't use CPAN"</a>, and the <a href="http://podcats.in/development/share-and-share-alike.html" class='external text' title="http://podcats.in/development/share-and-share-alike.html" rel="nofollow">continuation post by Altreus titled "Share and Share-Alike" for our motivation</a>. You may also get some help with some non-CPAN Perl code as long as you show some willingness to learn Perl, and <a href="http://community.livejournal.com/shlomif_tech/37969.html" class='external text' title="http://community.livejournal.com/shlomif_tech/37969.html" rel="nofollow">to modernise and/or refactor it if necessary</a>.

+</p><p>Please read what <a href="http://www.shadowcat.co.uk/blog/matt-s-trout/but-i-cant-use-cpan/" class='external text' title="http://www.shadowcat.co.uk/blog/matt-s-trout/but-i-cant-use-cpan/">Matt Trout (mst) wrote about "But I can't use CPAN"</a>, and the <a href="http://podcats.in/development/share-and-share-alike.html" class='external text' title="http://podcats.in/development/share-and-share-alike.html">continuation post by Altreus titled "Share and Share-Alike" for our motivation</a>. You may also get some help with some non-CPAN Perl code as long as you show some willingness to learn Perl, and <a href="http://community.livejournal.com/shlomif_tech/37969.html" class='external text' title="http://community.livejournal.com/shlomif_tech/37969.html">to modernise and/or refactor it if necessary</a>.

</p><p>If this is homework, and your professor gives some constraints on what you can use (*sigh*) or your pointy-haired-boss (PHB) is constraining you in various ways (double *sigh*), please mention it when asking your question and we may still help you if the non-CPAN-enabled solution is, while not ideal, is still doable elegantly.

</p>

<div class="editsection" style="float:right;margin-left:5px;">[<a href="http://perl.net.au/wiki/?title=Freenode_Sharp_Perl_FAQ&action=edit&section=9" title="Edit section: I need help with tweaking a Perl script that I found, and I don't want to learn Perl. Can you guys help me?">edit</a>]</div><a name="I_need_help_with_tweaking_a_Perl_script_that_I_found.2C_and_I_don.27t_want_to_learn_Perl._Can_you_guys_help_me.3F"></a><h3> I need help with tweaking a Perl script that I found, and I don't want to learn Perl. Can you guys help me? </h3>

<p>The best way to get assistance with a Perl problem is to demonstrate that you've taken some steps to try to find the answer yourself. This involves learning Perl enough to be able to fix the problem yourself. Learning Perl is not too hard and will prove useful into the future.

-</p><p>Alternatively, you can pay someone to help you. Just ask on the channel if someone wishes to be paid. If you're trying to modify a Perl script without <a href="http://perl.net.au/wiki/Learning_Perl" title="Learning Perl">learning Perl</a> (or paying someone who knows Perl) then we're not going to help. To quote <a href="http://en.wikipedia.org/wiki/Aesop" class='external text' title="http://en.wikipedia.org/wiki/Aesop" rel="nofollow">Aesop</a>: "The gods help them that help themselves.".

+</p><p>Alternatively, you can pay someone to help you. Just ask on the channel if someone wishes to be paid. If you're trying to modify a Perl script without <a href="http://perl.net.au/wiki/Learning_Perl" title="Learning Perl">learning Perl</a> (or paying someone who knows Perl) then we're not going to help. To quote <a href="http://en.wikipedia.org/wiki/Aesop" class='external text' title="http://en.wikipedia.org/wiki/Aesop">Aesop</a>: "The gods help them that help themselves.".

</p>

<div class="editsection" style="float:right;margin-left:5px;">[<a href="http://perl.net.au/wiki/?title=Freenode_Sharp_Perl_FAQ&action=edit&section=10" title="Edit section: I'd like to run a script (which I wrote or downloaded) on a cheap (or free) web-hosting that only gives me FTP. Can you help?">edit</a>]</div><a name="I.27d_like_to_run_a_script_.28which_I_wrote_or_downloaded.29_on_a_cheap_.28or_free.29_web-hosting_that_only_gives_me_FTP._Can_you_help.3F"></a><h3> I'd like to run a script (which I wrote or downloaded) on a cheap (or free) web-hosting that only gives me FTP. Can you help? </h3>

<p>Perl due to its architecture usually requires a bit more than an el-cheapo or "free" web-hosting. You need at least an ssh account, and often also a virtual server. There ain't no such thing as a free lunch. While many web-services are free, one has to understand that maintaining a server costs money, and the bandwidth costs money, and there's a lot of other costs. If you want something good, you have to pay for it, even in the modern Internet world. If you can't pay for it, you can try to find someone who'll host you free-of-charge, but note that it's also not trivial.

-</p><p>So please pay for hosting, have an ssh access, be able to install more CPAN modules, and let us know what the logs show. If you don't have money, just learn more Perl and become a Perl programmer. There's a huge demand for them, at the moment, and we could always <a href="http://perl-begin.org/learn/get-a-job/" class='external text' title="http://perl-begin.org/learn/get-a-job/" rel="nofollow">use your help</a>.

+</p><p>So please pay for hosting, have an ssh access, be able to install more CPAN modules, and let us know what the logs show. If you don't have money, just learn more Perl and become a Perl programmer. There's a huge demand for them, at the moment, and we could always <a href="http://perl-begin.org/learn/get-a-job/" class='external text' title="http://perl-begin.org/learn/get-a-job/">use your help</a>.

<p>If you're looking for assistance with a non-Perl problem, you've probably come to the wrong channel. You can try asking, but don't be surprised if you don't get an answer (or someone suggests you ask elsewhere) as Perl regular expressions are different from the regular expressions used by other programs and languages.

</p>

<div class="editsection" style="float:right;margin-left:5px;">[<a href="http://perl.net.au/wiki/?title=Freenode_Sharp_Perl_FAQ&action=edit&section=12" title="Edit section: Can you recommend a good Perl Editor/IDE?">edit</a>]</div><a name="Can_you_recommend_a_good_Perl_Editor.2FIDE.3F"></a><h3> Can you recommend a good Perl Editor/IDE? </h3>

-<dl><dd> This should look like <tt>#!/usr/bin/perl</tt> or <tt>#!/path/to/perl</tt>. On Windows you can just write <tt>#!perl</tt> but it is recommended to write <tt>#!/usr/bin/perl</tt> (Windows will ignore the path). If you're writing your program on one operating system and running it on another, check that your she-bang line does not contain any errant characters such as the <a href="http://en.wikipedia.org/wiki/Carriage_return" class='external text' title="http://en.wikipedia.org/wiki/Carriage_return" rel="nofollow">carriage return</a>. This won't be a problem if you're using any switches on this line.

+<dl><dd> This should look like <tt>#!/usr/bin/perl</tt> or <tt>#!/path/to/perl</tt>. On Windows you can just write <tt>#!perl</tt> but it is recommended to write <tt>#!/usr/bin/perl</tt> (Windows will ignore the path). If you're writing your program on one operating system and running it on another, check that your she-bang line does not contain any errant characters such as the <a href="http://en.wikipedia.org/wiki/Carriage_return" class='external text' title="http://en.wikipedia.org/wiki/Carriage_return">carriage return</a>. This won't be a problem if you're using any switches on this line.

</dd></dl>

<ol><li> If you're using Unix or a Unix-like operating system, check that your program is set to be executable (<tt>chmod a+x &lt;file&gt;</tt>).

-</li><li> When extracting arguments out of @ARGV or @_ , don't do subscripting of $ARGV[1] or $_[2] directly - instead use <a href="http://perldoc.perl.org/functions/shift.html" class='external text' title="http://perldoc.perl.org/functions/shift.html" rel="nofollow">perldoc -f shift</a> or <tt>my ($param1, $param2...) = @_;</tt>. The reason for that is that if you insert an argument in the middle, you'll need to update all indices.

+</li><li> When extracting arguments out of @ARGV or @_ , don't do subscripting of $ARGV[1] or $_[2] directly - instead use <a href="http://perldoc.perl.org/functions/shift.html" class='external text' title="http://perldoc.perl.org/functions/shift.html">perldoc -f shift</a> or <tt>my ($param1, $param2...) = @_;</tt>. The reason for that is that if you insert an argument in the middle, you'll need to update all indices.

<ul><li> For @ARGV also look at <a href="http://search.cpan.org/dist/Getopt-Long" class='extiw' title="cpan:Getopt-Long">Getopt-Long</a> and related modules.

</li></ul>

-</li><li> Don't abuse the default variable - <tt>$_</tt>. Use explicit variables instead whenever possible, and don't nest two <tt>$_</tt>-loops. While it should still be used in <a href="http://perldoc.perl.org/functions/map.html" class='external text' title="http://perldoc.perl.org/functions/map.html" rel="nofollow">map()</a>, <a href="http://perldoc.perl.org/functions/grep.html" class='external text' title="http://perldoc.perl.org/functions/grep.html" rel="nofollow">grep()</a>, etc. it should generally be avoided except for very small scripts.

+</li><li> Don't abuse the default variable - <tt>$_</tt>. Use explicit variables instead whenever possible, and don't nest two <tt>$_</tt>-loops. While it should still be used in <a href="http://perldoc.perl.org/functions/map.html" class='external text' title="http://perldoc.perl.org/functions/map.html">map()</a>, <a href="http://perldoc.perl.org/functions/grep.html" class='external text' title="http://perldoc.perl.org/functions/grep.html">grep()</a>, etc. it should generally be avoided except for very small scripts.

</li><li> To subscript an array/hash reference, don't do something like <tt>${$array_ref}[$index]</tt> (or worse - <tt>$$array_ref[$index]</tt> - instead use <tt>$array_ref-&gt;[$index]</tt> which is clearer and better. Note that if you want to take an array or hash slice, then you do need to use <tt>@{$array_ref}[@indexes]</tt> and that's ok.

<ul><li> Also note that the second and subsequent subscripts have optional arrows so: <tt>$array_ref-&gt;[$index1]-&gt;{$key1}</tt> can be written as <tt>$array_ref-&gt;[$index]{$key1}</tt>. The first arrow is not optional so you cannot say <tt>$array_ref[$index1]</tt> which belongs to the array <tt>@array_ref</tt>.

-</li><li> <a href="http://www.perltk.org/" class='external text' title="http://www.perltk.org/" rel="nofollow">Perl/Tk</a> - an old cross-platform toolkit, with a few limitations and a poor look and feel. Should be very flexible.

-</li><li> <a href="http://gtk2-perl.sourceforge.net/" class='external text' title="http://gtk2-perl.sourceforge.net/" rel="nofollow">Perl/Gtk2</a> - a GUI toolkit primarily intended for UNIXes, but also works on Windows with a very non-native look. wxWidgets uses it on UNIXes.

+</li><li> <a href="http://www.perltk.org/" class='external text' title="http://www.perltk.org/">Perl/Tk</a> - an old cross-platform toolkit, with a few limitations and a poor look and feel. Should be very flexible.

+</li><li> <a href="http://gtk2-perl.sourceforge.net/" class='external text' title="http://gtk2-perl.sourceforge.net/">Perl/Gtk2</a> - a GUI toolkit primarily intended for UNIXes, but also works on Windows with a very non-native look. wxWidgets uses it on UNIXes.

<div class="editsection" style="float:right;margin-left:5px;">[<a href="http://perl.net.au/wiki/?title=Freenode_Sharp_Perl_FAQ&action=edit&section=18" title="Edit section: How can I break/skip an outer loop?">edit</a>]</div><a name="How_can_I_break.2Fskip_an_outer_loop.3F"></a><h3> How can I break/skip an outer loop? </h3>

<div class="editsection" style="float:right;margin-left:5px;">[<a href="http://perl.net.au/wiki/?title=Freenode_Sharp_Perl_FAQ&action=edit&section=19" title="Edit section: How can I include a script into a different script and still see the lexical (&quot;my&quot;) variables declared there?">edit</a>]</div><a name="How_can_I_include_a_script_into_a_different_script_and_still_see_the_lexical_.28.22my.22.29_variables_declared_there.3F"></a><h3> How can I include a script into a different script and still see the lexical ("my") variables declared there? </h3>

<p>The short answer is that when a file is being <tt>do</tt>'ed, <tt>eval slurp($file)</tt>'ed, <tt>require</tt>'ed or

<p>If you want to access the variables of a different file, you need to declare them using <tt>our</tt> or the <tt>use vars</tt> pragma. A more advisable way would be to control access to them using functions.

<div class="editsection" style="float:right;margin-left:5px;">[<a href="http://perl.net.au/wiki/?title=Freenode_Sharp_Perl_FAQ&action=edit&section=20" title="Edit section: How can I format numbers with certain digits?">edit</a>]</div><a name="How_can_I_format_numbers_with_certain_digits.3F"></a><h3> How can I format numbers with certain digits? </h3>

<div class="editsection" style="float:right;margin-left:5px;">[<a href="http://perl.net.au/wiki/?title=Freenode_Sharp_Perl_FAQ&action=edit&section=21" title="Edit section: How can I have printf return a value instead of outputting to a filehandle?">edit</a>]</div><a name="How_can_I_have_printf_return_a_value_instead_of_outputting_to_a_filehandle.3F"></a><h3> How can I have printf return a value instead of outputting to a filehandle? </h3>

-<p>See <a href="http://perldoc.perl.org/functions/sprintf.html" class='external text' title="http://perldoc.perl.org/functions/sprintf.html" rel="nofollow">sprintf</a>. sprintf is like printf, only it returns the output as a string. Its use is preferable over printf most of the time. Note that its semantics are different than C's sprintf. In C you do:

+<p>See <a href="http://perldoc.perl.org/functions/sprintf.html" class='external text' title="http://perldoc.perl.org/functions/sprintf.html">sprintf</a>. sprintf is like printf, only it returns the output as a string. Its use is preferable over printf most of the time. Note that its semantics are different than C's sprintf. In C you do:

</p>

<pre> char buffer[1024];

sprintf(buffer, "%d Days until %s's birthday.", days, name);

<div class="editsection" style="float:right;margin-left:5px;">[<a href="http://perl.net.au/wiki/?title=Freenode_Sharp_Perl_FAQ&action=edit&section=22" title="Edit section: Where else can I go for help?">edit</a>]</div><a name="Where_else_can_I_go_for_help.3F"></a><h3> Where else can I go for help? </h3>

<div class="editsection" style="float:right;margin-left:5px;">[<a href="http://perl.net.au/wiki/?title=Freenode_Sharp_Perl_FAQ&action=edit&section=23" title="Edit section: How do I know the index of the element in a foreach loop?">edit</a>]</div><a name="How_do_I_know_the_index_of_the_element_in_a_foreach_loop.3F"></a><h3> How do I know the index of the element in a foreach loop? </h3>

<p>The short answer is that you don't. The obvious workaround is to write something like this:

<p>The longer answer is that there are often better ways to do it.

</p>

<div class="editsection" style="float:right;margin-left:5px;">[<a href="http://perl.net.au/wiki/?title=Freenode_Sharp_Perl_FAQ&action=edit&section=24" title="Edit section: Is there anyway to compile Perl code to an executable?">edit</a>]</div><a name="Is_there_anyway_to_compile_Perl_code_to_an_executable.3F"></a><h3> Is there anyway to compile Perl code to an executable? </h3>

-<p>One option is <a href="http://par.perl.org/" class='external text' title="http://par.perl.org/" rel="nofollow">PAR - The Perl Archiver</a>, which prepares an .exe that contains all your code, ready to run. This way is is easier to deploy on platforms that don't have perl5, some of the Perl modules or extensions, or certain C libraries.

+<p>One option is <a href="http://par.perl.org/" class='external text' title="http://par.perl.org/">PAR - The Perl Archiver</a>, which prepares an .exe that contains all your code, ready to run. This way is is easier to deploy on platforms that don't have perl5, some of the Perl modules or extensions, or certain C libraries.

</p><p>Alternatively, if you want to compile Perl code into machine code, then a partial solution was done by perlcc and the C:: namespace on CPAN. Note that it still includes the entire Perl run time (to handle string eval etc.), so it creates bloated executables.

-<p>First of all see <a href="http://perldoc.perl.org/File/Path.html" class='external text' title="http://perldoc.perl.org/File/Path.html" rel="nofollow">the File::Path module</a> and see if it has what you want. It can delete an entire directory tree as well as do the equivalent of "mkdir -p". To traverse an entire directory tree, see <a href="http://perladvent.pm.org/2006/2/" class='external text' title="http://perladvent.pm.org/2006/2/" rel="nofollow">File::Find and its equivalents.</a>.

+<p>First of all see <a href="http://perldoc.perl.org/File/Path.html" class='external text' title="http://perldoc.perl.org/File/Path.html">the File::Path module</a> and see if it has what you want. It can delete an entire directory tree as well as do the equivalent of "mkdir -p". To traverse an entire directory tree, see <a href="http://perladvent.pm.org/2006/2/" class='external text' title="http://perladvent.pm.org/2006/2/">File::Find and its equivalents.</a>.

+</p><p>To do the equivalent of "cp -R" (i.e: copy an entire directory tree recursively) in portable Perl, you'll either need to write something yourself or <a href="http://search.cpan.org/" class='external text' title="http://search.cpan.org/">find a good CPAN module for that</a>.

</p>

<div class="editsection" style="float:right;margin-left:5px;">[<a href="http://perl.net.au/wiki/?title=Freenode_Sharp_Perl_FAQ&action=edit&section=26" title="Edit section: I want to run a shell command from Perl, and possibly trap its output. How?">edit</a>]</div><a name="I_want_to_run_a_shell_command_from_Perl.2C_and_possibly_trap_its_output._How.3F"></a><h3> I want to run a shell command from Perl, and possibly trap its output. How? </h3>

-<p>1. To run a single command with arguments without making use of shell behaviour, and without capturing the output, the best way is to use <a href="http://perldoc.perl.org/functions/system.html" class='external text' title="http://perldoc.perl.org/functions/system.html" rel="nofollow">system(@args)</a>. You pass the system() function an array of parameters that encapsulate the executable name and its arguments. This makes sure special characters in the arguments are passed directly to the executable, without prior processing by the shell. The <tt>system("$str")</tt> notation, which is explained below has different semantics.

-</p><p>2. To do the same while capturing the output, the best way is to use <a href="http://perldoc.perl.org/perlopentut.html" class='external text' title="http://perldoc.perl.org/perlopentut.html" rel="nofollow">the open function</a> like this:

+<p>1. To run a single command with arguments without making use of shell behaviour, and without capturing the output, the best way is to use <a href="http://perldoc.perl.org/functions/system.html" class='external text' title="http://perldoc.perl.org/functions/system.html">system(@args)</a>. You pass the system() function an array of parameters that encapsulate the executable name and its arguments. This makes sure special characters in the arguments are passed directly to the executable, without prior processing by the shell. The <tt>system("$str")</tt> notation, which is explained below has different semantics.

+</p><p>2. To do the same while capturing the output, the best way is to use <a href="http://perldoc.perl.org/perlopentut.html" class='external text' title="http://perldoc.perl.org/perlopentut.html">the open function</a> like this:

</p>

<pre> open my $cmd, '-|', $program_name, @args

or die "Error in executing cmd. $!";

close($cmd);

</pre>

<p>Note that this will not work in some older versions of perl5.

-</p><p>3. If you do need to use special shell syntax (like pipelines, etc.) look at <a href="http://perldoc.perl.org/functions/system.html" class='external text' title="http://perldoc.perl.org/functions/system.html" rel="nofollow">system("$string")</a> or <a href="http://perldoc.perl.org/perlop.html#Quote-Like-Operators" class='external text' title="http://perldoc.perl.org/perlop.html#Quote-Like-Operators" rel="nofollow">the qx{...}/`...` operators</a> or the <tt>open "cmd|"</tt> syntax. However, be careful when interpolating arbitrary strings as arguments there, as if they are not properly escaped, they can be used to execute arbitrary shell code. Look at <a href="http://search.cpan.org/dist/String-ShellQuote/" class='external text' title="http://search.cpan.org/dist/String-ShellQuote/" rel="nofollow">the String-ShellQuote module</a> on the CPAN for a portable way to quote strings for passage as parameters to shell commands in such execution strings.

+</p><p>3. If you do need to use special shell syntax (like pipelines, etc.) look at <a href="http://perldoc.perl.org/functions/system.html" class='external text' title="http://perldoc.perl.org/functions/system.html">system("$string")</a> or <a href="http://perldoc.perl.org/perlop.html#Quote-Like-Operators" class='external text' title="http://perldoc.perl.org/perlop.html#Quote-Like-Operators">the qx{...}/`...` operators</a> or the <tt>open "cmd|"</tt> syntax. However, be careful when interpolating arbitrary strings as arguments there, as if they are not properly escaped, they can be used to execute arbitrary shell code. Look at <a href="http://search.cpan.org/dist/String-ShellQuote/" class='external text' title="http://search.cpan.org/dist/String-ShellQuote/">the String-ShellQuote module</a> on the CPAN for a portable way to quote strings for passage as parameters to shell commands in such execution strings.

</p><p>4. exec() is similar to system() and probably does not do what you want as it overwrites the current execution process of your Perl script with the new process.

</p>

<div class="editsection" style="float:right;margin-left:5px;">[<a href="http://perl.net.au/wiki/?title=Freenode_Sharp_Perl_FAQ&action=edit&section=27" title="Edit section: How can I Merge Two Hashes?">edit</a>]</div><a name="How_can_I_Merge_Two_Hashes.3F"></a><h3> How can I Merge Two Hashes? </h3>

</li><li> Usually, the performance gained by doing micro-optimisations in Perl is not going to be worth the trouble.

</li><li> If you really need performance for certain tasks that take too long, then you should probably look at a highly optimised solution written in a compiled-to-machine-code language. See Perl's XS or <a href="http://search.cpan.org/dist/Inline-C" class='extiw' title="cpan:Inline-C">cpan:Inline-C</a> for more information. However, going to this extreme is usually not what most people who ask us about performance want or need.

<div class="editsection" style="float:right;margin-left:5px;">[<a href="http://perl.net.au/wiki/?title=Freenode_Sharp_Perl_FAQ&action=edit&section=32" title="Edit section: Oh no! CPAN won't use the packages it has downloaded! It says the checksums are invalid!">edit</a>]</div><a name="Oh_no.21_CPAN_won.27t_use_the_packages_it_has_downloaded.21__It_says_the_checksums_are_invalid.21"></a><h3> Oh no! CPAN won't use the packages it has downloaded! It says the checksums are invalid! </h3>

<p>There are two reasons for this happening:

rm cpan-cycle.$$

</pre>

<div class="editsection" style="float:right;margin-left:5px;">[<a href="http://perl.net.au/wiki/?title=Freenode_Sharp_Perl_FAQ&action=edit&section=33" title="Edit section: How can I search for a value inside an array?">edit</a>]</div><a name="How_can_I_search_for_a_value_inside_an_array.3F"></a><h3> How can I search for a value inside an array? </h3>

-<p>See <a href="http://perldoc.perl.org/perlfaq4.html#How-can-I-tell-whether-a-certain-element-is-contained-in-a-list-or-array%3f" class='external text' title="http://perldoc.perl.org/perlfaq4.html#How-can-I-tell-whether-a-certain-element-is-contained-in-a-list-or-array%3f" rel="nofollow">the perlfaq question "How can I tell whether a certain element is contained in a list or array?"</a> for an exhaustive discussion of this topic. One final correction to it is that "any" from <a href="http://search.cpan.org/dist/List::MoreUtils" class='extiw' title="cpan:List::MoreUtils">cpan:List::MoreUtils</a> would sometimes be more preferable to "first", either to better convey the meaning that one is not interested in the value itself, but for its existence, and in the case that one is specifically looking for an undef() value.

+<p>See <a href="http://perldoc.perl.org/perlfaq4.html#How-can-I-tell-whether-a-certain-element-is-contained-in-a-list-or-array%3f" class='external text' title="http://perldoc.perl.org/perlfaq4.html#How-can-I-tell-whether-a-certain-element-is-contained-in-a-list-or-array%3f">the perlfaq question "How can I tell whether a certain element is contained in a list or array?"</a> for an exhaustive discussion of this topic. One final correction to it is that "any" from <a href="http://search.cpan.org/dist/List::MoreUtils" class='extiw' title="cpan:List::MoreUtils">cpan:List::MoreUtils</a> would sometimes be more preferable to "first", either to better convey the meaning that one is not interested in the value itself, but for its existence, and in the case that one is specifically looking for an undef() value.

<div class="editsection" style="float:right;margin-left:5px;">[<a href="http://perl.net.au/wiki/?title=Freenode_Sharp_Perl_FAQ&action=edit&section=34" title="Edit section: How can I prepare a self-contained Perl executable?">edit</a>]</div><a name="How_can_I_prepare_a_self-contained_Perl_executable.3F"></a><h3> How can I prepare a self-contained Perl executable? </h3>

<p>Look at <a href="http://perl.net.au/wiki/?title=PAR&action=edit" class="new" title="PAR">PAR</a> (the Perl archiver) or commercial alternatives such as perl2exe. They package the perl interpreter, the necessary perl modules, shared libraries, etc. into a self-contained .exe or .zip.

# Success

}

</pre>

-<p>And it will work. <b>However</b>, this will also insert special regular expression characters inside the regular expression, so if you have special characters like ".", "*", "+", "[" , "]", "{","?", etc. they can disrupt the match (or even open your code to security problems). To resolve this, you should refer to <a href="http://perldoc.perl.org/functions/quotemeta.html" class='external text' title="http://perldoc.perl.org/functions/quotemeta.html" rel="nofollow">perldoc -f quotemeta</a>, which allows quoting it and to the \Q and \E escapes inside regexes which allows quoting them with convenience. So our code becomes:

+<p>And it will work. <b>However</b>, this will also insert special regular expression characters inside the regular expression, so if you have special characters like ".", "*", "+", "[" , "]", "{","?", etc. they can disrupt the match (or even open your code to security problems). To resolve this, you should refer to <a href="http://perldoc.perl.org/functions/quotemeta.html" class='external text' title="http://perldoc.perl.org/functions/quotemeta.html">perldoc -f quotemeta</a>, which allows quoting it and to the \Q and \E escapes inside regexes which allows quoting them with convenience. So our code becomes:

</p>

<pre> if ($string =~ /\Q$needle\E/)

</pre>

-<p>Note that if you're interested in searching for a simple substring, then there are <a href="http://perldoc.perl.org/functions/quotemeta.html" class='external text' title="http://perldoc.perl.org/functions/quotemeta.html" rel="nofollow">perldoc -f index</a> and <a href="http://perldoc.perl.org/functions/quotemeta.html" class='external text' title="http://perldoc.perl.org/functions/quotemeta.html" rel="nofollow">perldoc -f rindex</a> for that which are faster than a regular expression match and potentially safer.

+<p>Note that if you're interested in searching for a simple substring, then there are <a href="http://perldoc.perl.org/functions/quotemeta.html" class='external text' title="http://perldoc.perl.org/functions/quotemeta.html">perldoc -f index</a> and <a href="http://perldoc.perl.org/functions/quotemeta.html" class='external text' title="http://perldoc.perl.org/functions/quotemeta.html">perldoc -f rindex</a> for that which are faster than a regular expression match and potentially safer.

</p>

<div class="editsection" style="float:right;margin-left:5px;">[<a href="http://perl.net.au/wiki/?title=Freenode_Sharp_Perl_FAQ&action=edit&section=39" title="Edit section: Where can I find lists of Programming Challenges?">edit</a>]</div><a name="Where_can_I_find_lists_of_Programming_Challenges.3F"></a><h3> Where can I find lists of Programming Challenges? </h3>

<p>Here are some lists:

</p>

-<ol><li> <a href="http://projecteuler.net/" class='external text' title="http://projecteuler.net/" rel="nofollow">Project Euler</a> - mathematical problems that one is expected to solve using a computer.

-</li><li> <a href="http://perl.plover.com/qotw/" class='external text' title="http://perl.plover.com/qotw/" rel="nofollow">Perl Quiz of the Week</a> - Used to be active, and people may still peruse the archives for problems and solutions. Note that newer challenges are only in the <a href="http://news.gmane.org/gmane.comp.lang.perl.qotw.discuss" class='external text' title="http://news.gmane.org/gmane.comp.lang.perl.qotw.discuss" rel="nofollow">qotw-discuss archives</a>.

+</li><li> <a href="http://perl.plover.com/qotw/" class='external text' title="http://perl.plover.com/qotw/">Perl Quiz of the Week</a> - Used to be active, and people may still peruse the archives for problems and solutions. Note that newer challenges are only in the <a href="http://news.gmane.org/gmane.comp.lang.perl.qotw.discuss" class='external text' title="http://news.gmane.org/gmane.comp.lang.perl.qotw.discuss">qotw-discuss archives</a>.

+<ul><li> The book <a href="http://mitpress.mit.edu/sicp/" class='external text' title="http://mitpress.mit.edu/sicp/">Structure and Interpretation of Computer Programs (SICP)</a> contains numerous exercises. Its text is available online.

</li></ul>

</li></ol>

<div class="editsection" style="float:right;margin-left:5px;">[<a href="http://perl.net.au/wiki/?title=Freenode_Sharp_Perl_FAQ&action=edit&section=40" title="Edit section: Where can I find an interactive version of Perl? (a.k.a a REPL - Read-Eval-Print-Loop)">edit</a>]</div><a name="Where_can_I_find_an_interactive_version_of_Perl.3F_.28a.k.a_a_REPL_-_Read-Eval-Print-Loop.29"></a><h3> Where can I find an interactive version of Perl? (a.k.a a REPL - Read-Eval-Print-Loop) </h3>

<div class="editsection" style="float:right;margin-left:5px;">[<a href="http://perl.net.au/wiki/?title=Freenode_Sharp_Perl_FAQ&action=edit&section=42" title="Edit section: How can I do a switch statement in Perl?">edit</a>]</div><a name="How_can_I_do_a_switch_statement_in_Perl.3F"></a><h3> How can I do a switch statement in Perl? </h3>

-<p>perl-5.10.x and later have a <a href="http://www.perlmonks.org/?node_id=709120" class='external text' title="http://www.perlmonks.org/?node_id=709120" rel="nofollow">given/when statement</a>. It is not available for perl-5.8.x and below.

-</p><p>There's also <a href="http://perldoc.perl.org/Switch.html" class='external text' title="http://perldoc.perl.org/Switch.html" rel="nofollow">Switch.pm</a> for earlier versions, but its use is not recommended because it's a source filter and tends to break a lot.

+<p>perl-5.10.x and later have a <a href="http://www.perlmonks.org/?node_id=709120" class='external text' title="http://www.perlmonks.org/?node_id=709120">given/when statement</a>. It is not available for perl-5.8.x and below.

+</p><p>There's also <a href="http://perldoc.perl.org/Switch.html" class='external text' title="http://perldoc.perl.org/Switch.html">Switch.pm</a> for earlier versions, but its use is not recommended because it's a source filter and tends to break a lot.

</p><p>Please consider using dispatch tables or if/elsif chains if you cannot use perl-5.10.x.

</p>

<div class="editsection" style="float:right;margin-left:5px;">[<a href="http://perl.net.au/wiki/?title=Freenode_Sharp_Perl_FAQ&action=edit&section=43" title="Edit section: How can I determine the type of a reference (array, hash, scalar, etc.)?">edit</a>]</div><a name="How_can_I_determine_the_type_of_a_reference_.28array.2C_hash.2C_scalar.2C_etc..29.3F"></a><h3> How can I determine the type of a reference (array, hash, scalar, etc.)? </h3>

# Will print MyPackage.

print 'ref($ref) = ', ref($ref), "\n";

</pre>

-<p>The built-in function <a href="http://perldoc.perl.org/functions/ref.html" class='external text' title="http://perldoc.perl.org/functions/ref.html" rel="nofollow">perldoc -f ref</a> demonstrated above will return the most basic class (in the OOP sense) that the reference is associated with (or its type if it isn't.). If you control the input and don't expect an edge case where it is was blessed, this would be OK.

+<p>The built-in function <a href="http://perldoc.perl.org/functions/ref.html" class='external text' title="http://perldoc.perl.org/functions/ref.html">perldoc -f ref</a> demonstrated above will return the most basic class (in the OOP sense) that the reference is associated with (or its type if it isn't.). If you control the input and don't expect an edge case where it is was blessed, this would be OK.

</p><p>If you want to find the most basic type of the reference, you should use Scalar::Util's reftype() function. Scalar::Util is a core module since perl-5.8.0, and is easily installable from CPAN for several older perls. (Which you really should avoid using).

-</p><p>Finally if you want to determine if an object reference belongs to a certain class you should use <a href="http://perldoc.perl.org/UNIVERSAL.html" class='external text' title="http://perldoc.perl.org/UNIVERSAL.html" rel="nofollow">the -&gt;isa() built-in-method</a> (from the UNIVERSAL class which is the implicit parent class of all other classes.). There has been some criticism against using such notations as:

+</p><p>Finally if you want to determine if an object reference belongs to a certain class you should use <a href="http://perldoc.perl.org/UNIVERSAL.html" class='external text' title="http://perldoc.perl.org/UNIVERSAL.html">the -&gt;isa() built-in-method</a> (from the UNIVERSAL class which is the implicit parent class of all other classes.). There has been some criticism against using such notations as:

</p><p>That put aside, since Perl 5 (and Perl 6) is a symbolic language, one can call a method by name on every object that supports it regardless of its actually inheritance geneology. So using <tt>-&gt;isa</tt> may be a red flag in Perl, and you should rethink your strategy.

<p>There is a way to do it, but you really shouldn't do it this way because it's most likely indicative of a bad design. Instead, pass the data to the module (preferably by defining a class (see <a href="http://search.cpan.org/dist/Moose" class='extiw' title="cpan:Moose">Moose</a> and other resources), instantiating an object and let it run. You can also implement an entire command line application as a module and a short, bootstrapping, script that invokes it.

</p>

<div class="editsection" style="float:right;margin-left:5px;">[<a href="http://perl.net.au/wiki/?title=Freenode_Sharp_Perl_FAQ&action=edit&section=46" title="Edit section: How can I set up a timeout for a blocking operation?">edit</a>]</div><a name="How_can_I_set_up_a_timeout_for_a_blocking_operation.3F"></a><h3> How can I set up a timeout for a blocking operation? </h3>

<div class="editsection" style="float:right;margin-left:5px;">[<a href="http://perl.net.au/wiki/?title=Freenode_Sharp_Perl_FAQ&action=edit&section=47" title="Edit section: How can I match (and possibly replace) the Nth expression out of a string?">edit</a>]</div><a name="How_can_I_match_.28and_possibly_replace.29_the_Nth_expression_out_of_a_string.3F"></a><h3> How can I match (and possibly replace) the Nth expression out of a string? </h3>

<p>Perl 5 does not provide a utilitarian built-in for doing that, but it is easy to do in several ways. The best way is probably to count the matches and replace them:

$string =~ s{(H)}{(++$count == 3)&nbsp;? "G"&nbsp;: $1}ge;

}

</pre>

-<p>You can also try using <a href="http://perl-begin.org/uses/text-parsing/#incremental-extraction" class='external text' title="http://perl-begin.org/uses/text-parsing/#incremental-extraction" rel="nofollow">\g and /g</a> or alternatively match the expression n-1 times and then replace it:

+<p>You can also try using <a href="http://perl-begin.org/uses/text-parsing/#incremental-extraction" class='external text' title="http://perl-begin.org/uses/text-parsing/#incremental-extraction">\g and /g</a> or alternatively match the expression n-1 times and then replace it:

</p>

<pre> my $pat = qr/H/;

$string =~ s{((?:$pat.*?){2})$pat}{${1}G};

</pre>

<div class="editsection" style="float:right;margin-left:5px;">[<a href="http://perl.net.au/wiki/?title=Freenode_Sharp_Perl_FAQ&action=edit&section=48" title="Edit section: How do I prepend data to a file, take out/delete data from the middle of the file or insert data into the middle of the file?">edit</a>]</div><a name="How_do_I_prepend_data_to_a_file.2C_take_out.2Fdelete_data_from_the_middle_of_the_file_or_insert_data_into_the_middle_of_the_file.3F"></a><h3> How do I prepend data to a file, take out/delete data from the middle of the file or insert data into the middle of the file? </h3>

<p>Files in UNIX can be thought of as big sequences of octets, and as such it is possible to overwrite existing bytes with new ones, to append to the end of the file, or to truncate a file from a position to the end (to create a file which is shorter than the existing one.). However, it's not easily possible to prepend data to the beginning of the file, to take out/delete data from the middle of the file or to insert it into the middle of the file while only using a single file handle to the file.

-</p><p>The best way to achieve what you want with such operations is to write a new file with the modified content, then close both files and move the new file on top of the existing files using <a href="http://perldoc.perl.org/functions/rename.html" class='external text' title="http://perldoc.perl.org/functions/rename.html" rel="nofollow">rename</a>. Here is an example for how to do a prepend:

+</p><p>The best way to achieve what you want with such operations is to write a new file with the modified content, then close both files and move the new file on top of the existing files using <a href="http://perldoc.perl.org/functions/rename.html" class='external text' title="http://perldoc.perl.org/functions/rename.html">rename</a>. Here is an example for how to do a prepend:

</p>

<pre> #!/usr/bin/perl

rename($new_fn, $filename);

</pre>

-<p>You can also look at higher-level abstractions such as <a href="http://perldoc.perl.org/Tie/File.html" class='external text' title="http://perldoc.perl.org/Tie/File.html" rel="nofollow">Tie::File</a> or <a href="http://search.cpan.org/dist/IO-All/" class='external text' title="http://search.cpan.org/dist/IO-All/" rel="nofollow">IO-All</a> for more idiomatic ways to achieve the same thing.

+<p>You can also look at higher-level abstractions such as <a href="http://perldoc.perl.org/Tie/File.html" class='external text' title="http://perldoc.perl.org/Tie/File.html">Tie::File</a> or <a href="http://search.cpan.org/dist/IO-All/" class='external text' title="http://search.cpan.org/dist/IO-All/">IO-All</a> for more idiomatic ways to achieve the same thing.

</p>

<div class="editsection" style="float:right;margin-left:5px;">[<a href="http://perl.net.au/wiki/?title=Freenode_Sharp_Perl_FAQ&action=edit&section=49" title="Edit section: How do I pass a reference to an object's method? (Also known as class subroutine or member function)">edit</a>]</div><a name="How_do_I_pass_a_reference_to_an_object.27s_method.3F_.28Also_known_as_class_subroutine_or_member_function.29"></a><h3> How do I pass a reference to an object's method? (Also known as class subroutine or member function) </h3>

<p>You have several options to pass a reference to a method, which differ in their syntax and semantics. Here is the list:

</li><li> You can pass the name of the method as a string and then do <tt>$some_obj-&gt;$some_method(@args)</tt>. This requires applying $some_method on an object explicitly and handles inheritance well.

</li></ol>

<div class="editsection" style="float:right;margin-left:5px;">[<a href="http://perl.net.au/wiki/?title=Freenode_Sharp_Perl_FAQ&action=edit&section=50" title="Edit section: How do I trim leading and/or trailing whitespace from a string?">edit</a>]</div><a name="How_do_I_trim_leading_and.2For_trailing_whitespace_from_a_string.3F"></a><h3> How do I trim leading and/or trailing whitespace from a string? </h3>

-<p>Some languages provide a built-in function to remove leading and/or trailing whitespace from a string (such as <a href="http://php.net/manual/en/function.trim.php" class='external text' title="http://php.net/manual/en/function.trim.php" rel="nofollow">PHP's trim</a>. Perl does not have it because it is fairly trivial to do using the <tt>s///</tt> built-in (see <a href="http://perl-begin.org/topics/regular-expressions/" class='external text' title="http://perl-begin.org/topics/regular-expressions/" rel="nofollow">our resources about regular expressions</a> and there's also <a href="http://search.cpan.org/dist/String-Trim" class='extiw' title="cpan:String-Trim">String-Trim on CPAN</a>.

+<p>Some languages provide a built-in function to remove leading and/or trailing whitespace from a string (such as <a href="http://php.net/manual/en/function.trim.php" class='external text' title="http://php.net/manual/en/function.trim.php">PHP's trim</a>. Perl does not have it because it is fairly trivial to do using the <tt>s///</tt> built-in (see <a href="http://perl-begin.org/topics/regular-expressions/" class='external text' title="http://perl-begin.org/topics/regular-expressions/">our resources about regular expressions</a> and there's also <a href="http://search.cpan.org/dist/String-Trim" class='extiw' title="cpan:String-Trim">String-Trim on CPAN</a>.

</p>

<div class="editsection" style="float:right;margin-left:5px;">[<a href="http://perl.net.au/wiki/?title=Freenode_Sharp_Perl_FAQ&action=edit&section=51" title="Edit section: How do I add directories to the list of paths where Perl searches for modules? (@INC)">edit</a>]</div><a name="How_do_I_add_directories_to_the_list_of_paths_where_Perl_searches_for_modules.3F_.28.40INC.29"></a><h3> How do I add directories to the list of paths where Perl searches for modules? (@INC) </h3>

<p>After that you can add <tt>use MyModule;</tt> to your code and it will work. Please don't resort to <tt>do "/full/path/to/include.pl"</tt> games.

</pre>

<div class="editsection" style="float:right;margin-left:5px;">[<a href="http://perl.net.au/wiki/?title=Freenode_Sharp_Perl_FAQ&action=edit&section=53" title="Edit section: I'm trying to use threads to speed up my program. What should I know?">edit</a>]</div><a name="I.27m_trying_to_use_threads_to_speed_up_my_program._What_should_I_know.3F"></a><h3> I'm trying to use threads to speed up my program. What should I know? </h3>

<p>Before you start implementing code using Perl's threads, please remember that Perl's threads are not like other threads.

-</p><p>Note that threads don't work too well in most C-hosted languages similar to Perl, such as Python or Ruby, and we recommend looking into a different language for that. Some people believe that threads should be avoided in any programming language (see for example Eric Raymond's <a href="http://www.catb.org/~esr/writings/taoup/html/ch07s03.html#id2923889" class='external text' title="http://www.catb.org/~esr/writings/taoup/html/ch07s03.html#id2923889" rel="nofollow">opinion about it</a> in the book <a href="http://www.catb.org/~esr/writings/taoup/" class='external text' title="http://www.catb.org/~esr/writings/taoup/" rel="nofollow"><i>The Art of Unix Programming</i></a>), but many people believe threads have many legitimate uses, when done properly. See also <a href="http://www.nntp.perl.org/group/perl.beginners/2011/02/msg115714.html" class='external text' title="http://www.nntp.perl.org/group/perl.beginners/2011/02/msg115714.html" rel="nofollow">this thread on the Perl beginners mailing list</a>.

+</p><p>Note that threads don't work too well in most C-hosted languages similar to Perl, such as Python or Ruby, and we recommend looking into a different language for that. Some people believe that threads should be avoided in any programming language (see for example Eric Raymond's <a href="http://www.catb.org/~esr/writings/taoup/html/ch07s03.html#id2923889" class='external text' title="http://www.catb.org/~esr/writings/taoup/html/ch07s03.html#id2923889">opinion about it</a> in the book <a href="http://www.catb.org/~esr/writings/taoup/" class='external text' title="http://www.catb.org/~esr/writings/taoup/"><i>The Art of Unix Programming</i></a>), but many people believe threads have many legitimate uses, when done properly. See also <a href="http://www.nntp.perl.org/group/perl.beginners/2011/02/msg115714.html" class='external text' title="http://www.nntp.perl.org/group/perl.beginners/2011/02/msg115714.html">this thread on the Perl beginners mailing list</a>.

</p>

<div class="editsection" style="float:right;margin-left:5px;">[<a href="http://perl.net.au/wiki/?title=Freenode_Sharp_Perl_FAQ&action=edit&section=54" title="Edit section: Should I be using mod_perl?">edit</a>]</div><a name="Should_I_be_using_mod_perl.3F"></a><h3> Should I be using mod_perl? </h3>

<p>The short answer is: "Most probably not.".

</p><p>mod_perl 1 was once the only sane way to run Perl scripts quickly on UNIX systems, however, it made a conscious choice of providing a lot of extra functionality, which proved to cost with complexity and sometimes quirkiness. Since then, FastCGI and similar technologies have matured (possibly legally) and there is now a new crop of popular web-servers, which aim to be very speedy (as well as less customisable and less suitable for hosting providers) such as <a href="http://www.wikipedia.org/wiki/Cherokee_%28webserver%29" class='extiw' title="wikipedia:Cherokee_(webserver)">Cherokee</a>, <a href="http://www.wikipedia.org/wiki/lighttpd" class='extiw' title="wikipedia:lighttpd">lighttpd</a> or <a href="http://www.wikipedia.org/wiki/nginx" class='extiw' title="wikipedia:nginx">nginx</a> that can utilise FastCGI as well, and you may opt to use instead of Apache, assuming your hosting is allows that.

-</p><p>So even if you're using Apache (and you should definitely use Apache 2 - not Apache 1), there are better alternatives for speeding up your applications than mod_perl, and you should only use mod_perl if you need more sophisticated control and functionality of Apache 2, in which case you may wish to also be asking that on <a href="http://perl.apache.org/maillist/modperl.html" class='external text' title="http://perl.apache.org/maillist/modperl.html" rel="nofollow">the mod_perl mailing list</a>, or on a similar forum, and you are expected to be an advanced user.

+</p><p>So even if you're using Apache (and you should definitely use Apache 2 - not Apache 1), there are better alternatives for speeding up your applications than mod_perl, and you should only use mod_perl if you need more sophisticated control and functionality of Apache 2, in which case you may wish to also be asking that on <a href="http://perl.apache.org/maillist/modperl.html" class='external text' title="http://perl.apache.org/maillist/modperl.html">the mod_perl mailing list</a>, or on a similar forum, and you are expected to be an advanced user.

</p>

<div class="editsection" style="float:right;margin-left:5px;">[<a href="http://perl.net.au/wiki/?title=Freenode_Sharp_Perl_FAQ&action=edit&section=55" title="Edit section: How can I find which modules a Perl program or module depends on?">edit</a>]</div><a name="How_can_I_find_which_modules_a_Perl_program_or_module_depends_on.3F"></a><h3> How can I find which modules a Perl program or module depends on? </h3>

<p>If you wish to use it on an program you have on the disk at run-time, then use <a href="http://search.cpan.org/dist/Devel-TraceUse" class='extiw' title="cpan:Devel-TraceUse">Devel-TraceUse</a>, which will report the used modules recursively.

-</p><p>One can also use the <a href="http://deps.cpantesters.org/" class='external text' title="http://deps.cpantesters.org/" rel="nofollow">CPAN dependencies</a> tool to determine the dependencies of a CPAN distribution or module.

+</p><p>One can also use the <a href="http://deps.cpantesters.org/" class='external text' title="http://deps.cpantesters.org/">CPAN dependencies</a> tool to determine the dependencies of a CPAN distribution or module.

<p>The <a href="http://perl.net.au/wiki/Freenode_Sharp_Perlcafe" title="Freenode Sharp Perlcafe">Perl Café</a> exists to move off-topic discussions out of #perl. The channel is very lax, but often heavy on the irony. Examples of conversation include:

<p>Discussion for the development of <a href="http://perl.net.au/wiki/Perl_6" title="Perl 6">Perl 6</a>, <a href="http://perl.net.au/wiki/Pugs" title="Pugs">Pugs</a> and <a href="http://perl.net.au/wiki/?title=Rakudo&action=edit" class="new" title="Rakudo">Rakudo</a>, and as usual on Freenode, a lot of off-topic discussion. Don't ask Perl 5 technical questions there - ask them on #perl.

-<p><a href="irc://irc.freenode.net/lispcafe" class='external text' title="irc://irc.freenode.net/lispcafe" rel="nofollow">#lispcafe</a> is an off-shoot of #lisp and #perlcafe. The primary lisp channel #lisp is restricted to "on-topic" discussion of Common Lisp. Thus #lispcafe was founded to accept off-topic discussions. Unlike #perlcafe, #lispcafe attempts to be more civil. Discussions of Perl and other dynamic languages is acceptable on #lispcafe, so you might wish to visit it, introduce yourself and join the fun.

+<p><a href="irc://irc.freenode.net/lispcafe" class='external text' title="irc://irc.freenode.net/lispcafe">#lispcafe</a> is an off-shoot of #lisp and #perlcafe. The primary lisp channel #lisp is restricted to "on-topic" discussion of Common Lisp. Thus #lispcafe was founded to accept off-topic discussions. Unlike #perlcafe, #lispcafe attempts to be more civil. Discussions of Perl and other dynamic languages is acceptable on #lispcafe, so you might wish to visit it, introduce yourself and join the fun.

</p>

-<ol><li>lispcafe has <a href="http://www.cliki.net/lispcafe" class='external text' title="http://www.cliki.net/lispcafe" rel="nofollow">its own page</a> on the Common Lisp wiki.

+<ol><li>lispcafe has <a href="http://www.cliki.net/lispcafe" class='external text' title="http://www.cliki.net/lispcafe">its own page</a> on the Common Lisp wiki.

<p>Since many #perl'ers either like cats or even sometimes emulate ones, a channel was started for all things cats and Perl. It is pretty small, and we discuss many things besides cats. Some people there are just friends of regular #perl'ers (who also happen to like Perl). #perl-cats tends to be more civil than #perlcafe , but expect a lot of cat overload.

-<p>He's just some guy, you know? apeiron is a USian with dreams of moving to Europe. As with most people and bots depicted here, Perl is his favorite language. Of the <a href="http://typelogic.com/intj.html" class='external text' title="http://typelogic.com/intj.html" rel="nofollow">INTJ</a> personality type, he tends to focus more on solving problems than being the center of attention. Insatiably curious, he enjoys playing with new frameworks and applications. His interests are in free culture, free software, science, history, anthropology, music, philosophy, Shakespeare, and many other things. To be brief: a geek and a hippie.

+<p>He's just some guy, you know? apeiron is a USian with dreams of moving to Europe. As with most people and bots depicted here, Perl is his favorite language. Of the <a href="http://typelogic.com/intj.html" class='external text' title="http://typelogic.com/intj.html">INTJ</a> personality type, he tends to focus more on solving problems than being the center of attention. Insatiably curious, he enjoys playing with new frameworks and applications. His interests are in free culture, free software, science, history, anthropology, music, philosophy, Shakespeare, and many other things. To be brief: a geek and a hippie.

<p>beth lives in <a href="http://www.wikipedia.org/wiki/Ithaca%2C_New_York" class='extiw' title="wikipedia:Ithaca,_New_York">Ithaca, New York</a>. She works with Perl at Cornell university as a <a href="http://www.wikipedia.org/wiki/Bioinformatics" class='extiw' title="wikipedia:Bioinformatics">bioinformatics</a> analyst and is one of #perl's resident gurus.

-<p>Chris is an American living in Las Vegas. He's the author and maintainer of <a href="http://chrisangell.com/incoming/chrisbot/v3" class='external text' title="http://chrisangell.com/incoming/chrisbot/v3" rel="nofollow">ChrisBot</a>, which is the codebase behind "perlbot", our resident infobot. He is rather hands-off when it comes to policing the channel and believes in minimal usage of operator privileges. In his spare time he enjoys spending time at the shooting range, eating sushi, and drinking beer with his friends.

+<p>Chris is an American living in Las Vegas. He's the author and maintainer of <a href="http://chrisangell.com/incoming/chrisbot/v3" class='external text' title="http://chrisangell.com/incoming/chrisbot/v3">ChrisBot</a>, which is the codebase behind "perlbot", our resident infobot. He is rather hands-off when it comes to policing the channel and believes in minimal usage of operator privileges. In his spare time he enjoys spending time at the shooting range, eating sushi, and drinking beer with his friends.

-<p>I am he. While coding I like to have a candle burning, and the sun setting. I try to treat IRC as <a href="http://en.wikipedia.org/wiki/BitTorrent" class='external text' title="http://en.wikipedia.org/wiki/BitTorrent" rel="nofollow">BitTorrent</a> for programming knowledge and am often looking for short term perl contracts, ideally telecommute. You may find I behave like a cat from time to time, this is a <a href="http://www.netjeff.com/humor/item.cgi?file=hire.txt" class='external text' title="http://www.netjeff.com/humor/item.cgi?file=hire.txt" rel="nofollow">desired behaviour</a> and not a bug.

+<p>I am he. While coding I like to have a candle burning, and the sun setting. I try to treat IRC as <a href="http://en.wikipedia.org/wiki/BitTorrent" class='external text' title="http://en.wikipedia.org/wiki/BitTorrent">BitTorrent</a> for programming knowledge and am often looking for short term perl contracts, ideally telecommute. You may find I behave like a cat from time to time, this is a <a href="http://www.netjeff.com/humor/item.cgi?file=hire.txt" class='external text' title="http://www.netjeff.com/humor/item.cgi?file=hire.txt">desired behaviour</a> and not a bug.

-<p>mst is the project founder of DBIx::Class, member of the Catalyst core team and lead tech at <a href="http://www.shadowcat.co.uk/" class='external text' title="http://www.shadowcat.co.uk/" rel="nofollow">Shadowcat Systems</a>. He's also a sarcastic obnoxious english guy with a very dry sense of humour. Also known as "wielder of the chainsaw" for his high impact LARTing technique when somebody isn't paying attention to the people trying to help them.

+<p>mst is the project founder of DBIx::Class, member of the Catalyst core team and lead tech at <a href="http://www.shadowcat.co.uk/" class='external text' title="http://www.shadowcat.co.uk/">Shadowcat Systems</a>. He's also a sarcastic obnoxious english guy with a very dry sense of humour. Also known as "wielder of the chainsaw" for his high impact LARTing technique when somebody isn't paying attention to the people trying to help them.

-<p>rindolf, also known as <a href="http://www.shlomifish.org/" class='external text' title="http://www.shlomifish.org/" rel="nofollow">Shlomi Fish</a>, or "shlomif", is an Israeli programmer born in 1977. He tries to be as helpful and friendly as possible and often is too friendly. If he expresses interest in you, either just answer his questions, or tell him to stop.

-</p><p>Shlomi has many interests including: programming and software development, open-source use, development and advocacy, creative writing, applied philosophy and writing essays, biking, science, logic and applied logic, cognitive psychology, mathematics and puzzles, linguistics, history of the Old World, etc. He has a Bachelor of Science from <a href="http://www.shlomifish.org/philosophy/computers/education/opinion-on-the-technion/" class='external text' title="http://www.shlomifish.org/philosophy/computers/education/opinion-on-the-technion/" rel="nofollow">the Technion in Electrical Engineering</a>, but thinks it would be a stretch to call him an Electrical Engineer.

+<p>rindolf, also known as <a href="http://www.shlomifish.org/" class='external text' title="http://www.shlomifish.org/">Shlomi Fish</a>, or "shlomif", is an Israeli programmer born in 1977. He tries to be as helpful and friendly as possible and often is too friendly. If he expresses interest in you, either just answer his questions, or tell him to stop.

+</p><p>Shlomi has many interests including: programming and software development, open-source use, development and advocacy, creative writing, applied philosophy and writing essays, biking, science, logic and applied logic, cognitive psychology, mathematics and puzzles, linguistics, history of the Old World, etc. He has a Bachelor of Science from <a href="http://www.shlomifish.org/philosophy/computers/education/opinion-on-the-technion/" class='external text' title="http://www.shlomifish.org/philosophy/computers/education/opinion-on-the-technion/">the Technion in Electrical Engineering</a>, but thinks it would be a stretch to call him an Electrical Engineer.

</p><p>Perl is his favourite language. Among his contributions to the Perl world are:

-<p>alanhaggai is a programmer and web developer who got converted to Perl. He maintains <a href="http://alanhaggai.org/" class='external text' title="http://alanhaggai.org/" rel="nofollow">a website at http://alanhaggai.org/</a> where he experiments with new CSS designs. He also maintains <a href="http://use.perl.org/~alanhaggai/journal/" class='external text' title="http://use.perl.org/~alanhaggai/journal/" rel="nofollow">a use Perl journal</a>.

+<p>alanhaggai is a programmer and web developer who got converted to Perl. He maintains <a href="http://alanhaggai.org/" class='external text' title="http://alanhaggai.org/">a website at http://alanhaggai.org/</a> where he experiments with new CSS designs. He also maintains <a href="http://use.perl.org/~alanhaggai/journal/" class='external text' title="http://use.perl.org/~alanhaggai/journal/">a use Perl journal</a>.

-<p>dazjorz is a Perl programmer by the name of Sjors Gielen. He mainly programs servers. His bot is DaZeus, but it's not in #perl, to his deep disappointment. His personal web site is at <a href="http://dazjorz.com/" class='external free' title="http://dazjorz.com/" rel="nofollow">http://dazjorz.com/</a>.

+<p>dazjorz is a Perl programmer by the name of Sjors Gielen. He mainly programs servers. His bot is DaZeus, but it's not in #perl, to his deep disappointment. His personal web site is at <a href="http://dazjorz.com/" class='external free' title="http://dazjorz.com/">http://dazjorz.com/</a>.

<p>whoppix considers himself to be a rather average perl programmer. He does not have a livejournal, a blog, a website, a twitter account, or almost anything else web2.0 related. He is not at all interested and/or skilled in webdesign, relational databases and/or anything derived thereof.

<pre>f00li5h&gt; GumbyBRAIN: what do you want me to say about you in the wiki?

GumbyBRAIN&gt; I was wondering if there are reportadly some non-drm songs, it's like bla bla bla bla and no you really want do.

</pre>

-<p>GumbyBRAIN is BinGOs' experimental megahal bot and not an infobot (despite appearances to the contrary). Source at <a href="http://www.gumbybrain.com/" class='external free' title="http://www.gumbybrain.com/" rel="nofollow">http://www.gumbybrain.com/</a>

+<p>GumbyBRAIN is BinGOs' experimental megahal bot and not an infobot (despite appearances to the contrary). Source at <a href="http://www.gumbybrain.com/" class='external free' title="http://www.gumbybrain.com/">http://www.gumbybrain.com/</a>

<p>Yet another bot written in perl created for testing the Math::Farnsworth module created by simcop2387, it features a Turing-complete programming language that rules all of its "commands". Its primary function is for doing math with unit tracking and conversions, but it will also do language conversions, and date manipulation also.