perl.beginners http://www.nntp.perl.org/group/perl.beginners/ ... Copyright 1998-2013 perl.org Wed, 22 May 2013 15:27:29 +0000 ask@perl.org Re: begining by Shlomi Fish Hi Ray,<br/><br/>On Sun, 19 May 2013 17:10:03 +0100<br/>Rahim Fakir &lt;rahim.g.fakir@gmail.com&gt; wrote:<br/><br/>&gt; Can someone tell me or give a adress to programs like hello world or<br/>&gt; similar, for practice.<br/><br/>See:<br/><br/>http://perl-begin.org/exercises/<br/><br/>( Note that http://perl-begin.org/ is a site I happen to maintain. )<br/><br/>&gt; Iam beging practice programming, and bought a book of perl, but i need<br/>&gt; program to practice can someone give me a hand.<br/><br/>Which book did you buy? For lists of recommended books and tutorials, see:<br/><br/>* http://perl-tutorial.org/<br/><br/>* http://perl-begin.org/tutorials/<br/><br/>* http://perl-begin.org/books/<br/><br/>Regards,<br/><br/> Shlomi Fish<br/><br/>-- <br/>-----------------------------------------------------------------<br/>Shlomi Fish http://www.shlomifish.org/<br/>UNIX Fortune Cookies - http://www.shlomifish.org/humour/fortunes/<br/><br/>Tcl is Lisp on drugs. Using strings instead of S&#x2010;expressions for closures is<br/>Evil with one of those gigantic E&rsquo;s you can find at the beginning of chapters.<br/><br/>Please reply to list if it&#39;s a mailing list post - http://shlom.in/reply .<br/> http://www.nntp.perl.org/group/perl.beginners/2013/05/msg122899.html Mon, 20 May 2013 08:47:40 +0000 Re: begining by Peter Gordon &lt;HTML&gt;&lt;HEAD&gt;<br/>&lt;BASEFONT FACE=&quot;Arial&quot; SIZE=&quot;3&quot; COLOR=&quot;#000000&quot;&gt;<br/>&lt;/HEAD&gt;<br/>&lt;BODY&gt;<br/>&lt;div&gt;On Sun, 19 May 2013 09:16:33 -0700, John SJ Anderson wrote:&lt;br&gt;&lt;/div&gt;<br/>&lt;div&gt;&lt;br&gt;<br/>&lt;FONT COLOR=&quot;#000080&quot;&gt;&amp;gt;&lt;/FONT&gt;Our FAQ has a list of recommended resources: &lt;a href=&quot;http://www.perl.org/learn/faq/beginners.html#books&quot;&gt;http://www.perl.org/learn/faq/beginners.html#books&lt;/a&gt;&lt;br&gt;<br/>&lt;br&gt;&lt;/div&gt;<br/>&lt;div&gt;Heck, that list is dated.&amp;nbsp; Learning Perl is now in it&#39;s 6 th edition.&lt;br&gt;&lt;/div&gt;<br/>&lt;div&gt;&amp;nbsp;&lt;/div&gt;<br/>&lt;div&gt;-- &lt;br&gt;&lt;/div&gt;<br/>&lt;div&gt;Peter Gordon, petergo@netspace.net.au on 05/20/2013&lt;br&gt;&lt;/div&gt;<br/>&lt;/body&gt;&lt;/html&gt;<br/><br/><br/> http://www.nntp.perl.org/group/perl.beginners/2013/05/msg122898.html Sun, 19 May 2013 20:27:11 +0000 Re: DBD::mysqlPP is giving out of memory exception and ODBC isworking fine. by Ganesh Babu N Dear Shlomi Fish,<br/>.<br/>Thank you for pointing to the right website I will follow the rules.<br/><br/>The above code is only part of the large program. I have posted only the<br/>Database related portion only.<br/><br/>Regards,<br/>Ganesh<br/><br/>On Sun, May 19, 2013 at 1:38 PM, Shlomi Fish &lt;shlomif@shlomifish.org&gt; wrote:<br/><br/>&gt; Hi Ganesh,<br/>&gt;<br/>&gt; On Sat, 18 May 2013 20:11:09 +0530<br/>&gt; Ganesh Babu N &lt;nbabuganesh@gmail.com&gt; wrote:<br/>&gt;<br/>&gt; &gt; $dbh = DBI-&gt;connect(&quot;dbi:mysqlPP:$dsn;host=$host&quot;, $user, $pw,<br/>&gt; &gt; {PrintError =&gt; 1, RaiseError =&gt; 1});<br/>&gt; &gt; if (!$dbh) {<br/>&gt; &gt; print &quot;error: connection: $DBI::err\n$DBI::errstr\n$DBI::state\n&quot;;<br/>&gt; &gt; }<br/>&gt; &gt; $drh = DBI-&gt;install_driver(&quot;mysqlPP&quot;);<br/>&gt; &gt; $ary_ref = $dbh-&gt;selectcol_arrayref(&quot;SELECT pui,spuid FROM inven WHERE<br/>&gt; &gt; dispatchdate=\&quot;0000-00-00\&quot; and dupli is NULL LIMIT 0, 5000&quot;, {<br/>&gt; &gt; Columns=&gt;[1,2] });<br/>&gt; &gt; %masterdb = @$ary_ref; # build hash from key-value pairs so $hash{$id} =&gt;<br/>&gt; &gt; name<br/>&gt; &gt; $sth = $dbh-&gt;prepare(&quot;SELECT DISTINCT spuid FROM inven WHERE<br/>&gt; &gt; dispatchdate&lt;&gt;\&quot;0000-00-00\&quot; and dupli is NULL LIMIT 0, 1000&quot;);<br/>&gt; &gt; $sth-&gt;execute();<br/>&gt; &gt; while ( @row = $sth-&gt;fetchrow_array ) {<br/>&gt; &gt; push(@dspu, &quot;@row\.dat&quot;);<br/>&gt; &gt; }<br/>&gt;<br/>&gt; This code is really bad:<br/>&gt;<br/>&gt; 1. It lacks &quot;use strict;&quot; and &quot;use warnings;&quot;.<br/>&gt;<br/>&gt; 2. It doesn&#39;t throw an exception when &quot;$dbh&quot; is undef.<br/>&gt;<br/>&gt; 3. It is not properly indented.<br/>&gt;<br/>&gt; 4. It lacks empty lines between code paragraphs.<br/>&gt;<br/>&gt; Please fix all those. See the link<br/>&gt; http://perl-begin.org/tutorials/bad-elements/ on The Perl Beginners Site,<br/>&gt; which<br/>&gt; is a site I maintain.<br/>&gt;<br/>&gt; &gt;<br/>&gt; &gt; The above code which uses mysqlPP module is giving our of memory<br/>&gt; exception<br/>&gt; &gt; and not getting executed.<br/>&gt;<br/>&gt; Why are you using mysqlPP instead of<br/>&gt; https://metacpan.org/release/DBD-mysql ?<br/>&gt;<br/>&gt; DBD::mysql is asking for mysql.dll in the module folder when we create EXE<br/>using PDK which is not present. I am using Activestate Perl<br/><br/><br/>&gt; &gt;<br/>&gt; &gt; Where as if it uses ODBC connection it is working without any exception.<br/>&gt; &gt;<br/>&gt; &gt; first query will fetch 3000 records and 2nd query fetches 500 records. it<br/>&gt; &gt; may increase in later stages.<br/>&gt; &gt;<br/>&gt; &gt; $dbh = DBI-&gt;connect(&quot;dbi:ODBC:$dsn&quot;, $user, $pw,<br/>&gt; &gt; {PrintError =&gt; 1, RaiseError =&gt; 1});<br/>&gt; &gt; if (!$dbh) {<br/>&gt; &gt; print &quot;error: connection: $DBI::err\n$DBI::errstr\n$DBI::state\n&quot;;<br/>&gt; &gt; }<br/>&gt; &gt;<br/>&gt; &gt; is there any bug in mysqlPP? or am i missing something obvious.<br/>&gt; &gt;<br/>&gt;<br/>&gt; There may be.<br/>&gt;<br/>&gt; &gt; Please help in resolving this error.<br/>&gt; &gt;<br/>&gt; &gt; Regards,<br/>&gt; &gt; Ganesh<br/>&gt;<br/>&gt;<br/>&gt; Regards,<br/>&gt;<br/>&gt; Shlomi Fish<br/>&gt;<br/>&gt;<br/>&gt; --<br/>&gt; -----------------------------------------------------------------<br/>&gt; Shlomi Fish http://www.shlomifish.org/<br/>&gt; List of Portability Libraries - http://shlom.in/port-libs<br/>&gt;<br/>&gt; For every A, Chuck Norris is both A and not-A.<br/>&gt; Chuck Norris is freaking everything.<br/>&gt; &mdash; http://www.shlomifish.org/humour/bits/facts/Chuck-Norris/<br/>&gt;<br/>&gt; Please reply to list if it&#39;s a mailing list post - http://shlom.in/reply .<br/>&gt;<br/>&gt; --<br/>&gt; To unsubscribe, e-mail: beginners-unsubscribe@perl.org<br/>&gt; For additional commands, e-mail: beginners-help@perl.org<br/>&gt; http://learn.perl.org/<br/>&gt;<br/>&gt;<br/>&gt;<br/><br/> http://www.nntp.perl.org/group/perl.beginners/2013/05/msg122897.html Sun, 19 May 2013 17:42:06 +0000 Re: begining by John SJ Anderson On Sun, May 19, 2013 at 9:10 AM, Rahim Fakir &lt;rahim.g.fakir@gmail.com&gt;wrote:<br/><br/>&gt; Can someone tell me or give a adress to programs like hello world or<br/>&gt; similar, for practice.<br/>&gt; Iam beging practice programming, and bought a book of perl, but i need<br/>&gt; program to practice can someone give me a hand.<br/>&gt;<br/>&gt;<br/>You haven&#39;t really asked much of a clear question there. Perhaps try again?<br/><br/>If you&#39;ve got a book, it should contain some sample programs, ideally in<br/>the first chapter. If your book doesn&#39;t, you may want to get a better book.<br/><br/>Our FAQ has a list of recommended resources:<br/>http://www.perl.org/learn/faq/beginners.html#books<br/><br/>chrs,<br/>john.<br/><br/> http://www.nntp.perl.org/group/perl.beginners/2013/05/msg122896.html Sun, 19 May 2013 16:16:44 +0000 begining by Rahim Fakir Can someone tell me or give a adress to programs like hello world or<br/>similar, for practice.<br/>Iam beging practice programming, and bought a book of perl, but i need<br/>program to practice can someone give me a hand.<br/>Best Regards<br/>Ray<br/><br/> http://www.nntp.perl.org/group/perl.beginners/2013/05/msg122895.html Sun, 19 May 2013 16:10:14 +0000 issue with threaded IO::Socket::INET by Chris Knipe Hi All,<br/><br/>I have an issue with a small piece of code. I am using IO::Socket::INET to<br/>accept client connections from an socket, and then hand the connection off<br/>to an newly created thread. As soon as an client disconnects (or interrupts<br/>the tcp session), the script will exit completely. No errors, and the<br/>application doesn&#39;t exist the while loop either (the print after the loop<br/>isn&#39;t executed). It almost seems that the main thread is killed?<br/><br/>my $Queue :shared; # Shared reference to our Queued<br/>work<br/>my $num_of_threads = 2; # Maximum number of threads to start<br/>my @Threads; # An array holding an reference to<br/>our threads<br/>my $SocketAddress = &quot;198.19.255.11&quot;;<br/>my $SocketPort = 2000;<br/><br/># This is the main threads serving the socket connections<br/>sub ProcessClient {<br/> my ($Client,$Queue) = @_;<br/> while ($Client) {<br/> my $MessageID = &lt;$Client&gt;;<br/> if ($MessageID &amp;&amp; length($MessageID) &gt; 8) {<br/> $MessageID =~ s/\r?\n$//;<br/> my $Result = $Queue-&gt;enqueue_and_wait($MessageID);<br/> my ($Content) = @$Result;<br/> print $Client $Content;<br/> } else {<br/> print $Client &quot;Invalid Message-ID\n.\n&quot;;<br/> }<br/> }<br/>}<br/><br/># This is the main threads fetching<br/>sub ThreadWorking {<br/> my ($Queue) = @_;<br/> print &quot;Starting Fetcher Thread: &quot; . $$ . &quot;.&quot; . threads-&gt;tid . &quot;\n&quot;;<br/> ... code ommited ...<br/>}<br/><br/>### Main Processing Section<br/># Flush buffers after ever write, and setup some other parameters<br/>$| = 1;<br/>select(STDOUT);<br/>setpriority (0,0,20);<br/><br/># Start the main queue and threads<br/>$Queue = Thread::Queue::Duplex-&gt;new(ListenerRequired =&gt; 0,<br/> MaxPending =&gt; 1024);<br/>for my $Count (1 .. $num_of_threads) {<br/> my $QueueWorker = threads-&gt;create(\&amp;ThreadWorking, $Queue);<br/> $QueueWorker-&gt;detach();<br/> push (@Threads, $QueueWorker);<br/>}<br/><br/>print &quot;Waiting for Queue Listeners to become ready...\n&quot;;<br/>$Queue-&gt;wait_for_listener();<br/>sleep(5);<br/><br/># Start our main listening socket<br/>my $Socket = IO::Socket::INET-&gt;new(LocalAddress =&gt; $SocketAddress,<br/> LocalPort =&gt; $SocketPort,<br/> Proto =&gt; &quot;tcp&quot;,<br/> Type =&gt; SOCK_STREAM,<br/> Listen =&gt; SOMAXCONN,<br/> ReuseAddr =&gt; 1) or die &quot;Can&#39;t create<br/>listen socket: $!&quot;;<br/>$Socket-&gt;autoflush(1);<br/>while (1) {<br/> my $Client;<br/> do {<br/> $Client = $Socket-&gt;accept();<br/> $Client-&gt;autoflush(1);<br/> } until (defined($Client));<br/> my $ClientThread = threads-&gt;create(\&amp;ProcessClient, $Client,<br/>$Queue)-&gt;detach;<br/> push (@Threads, $ClientThread);<br/> print &quot;Connection received from &quot; . $Client-&gt;peerhost() . &quot;:&quot; .<br/>$Client-&gt;peerport() . &quot;\n&quot;;<br/>}<br/>print &quot;exited while loop\n&quot;;<br/><br/><br/>Output:<br/>root@netty:/opt/bin# ./threads <br/>Starting Fetcher Thread: 17963.1<br/>Waiting for Queue Listeners to become ready...<br/>Starting Fetcher Thread: 17963.2<br/>OK: Tread: 17963.001, Time: 1.212, Ready to work<br/>OK: Tread: 17963.002, Time: 1.210, Ready to work<br/>Connection received from 198.19.255.3:37991<br/>root@NNTPWEB01:/srv/nntp/bin#<br/><br/>I&#39;ve tried various ways to do the while loop, but pretty much everything is<br/>showing the same results, which is why I&#39;m thinking more towards that<br/>there&#39;s an threading issue... <br/><br/>I would appreciate any assistance.<br/><br/>--<br/>Chris.<br/><br/><br/> http://www.nntp.perl.org/group/perl.beginners/2013/05/msg122894.html Sun, 19 May 2013 10:14:21 +0000 Re: DBD::mysqlPP is giving out of memory exception and ODBC isworking fine. by Shlomi Fish Hi Ganesh,<br/><br/>On Sat, 18 May 2013 20:11:09 +0530<br/>Ganesh Babu N &lt;nbabuganesh@gmail.com&gt; wrote:<br/><br/>&gt; $dbh = DBI-&gt;connect(&quot;dbi:mysqlPP:$dsn;host=$host&quot;, $user, $pw,<br/>&gt; {PrintError =&gt; 1, RaiseError =&gt; 1});<br/>&gt; if (!$dbh) {<br/>&gt; print &quot;error: connection: $DBI::err\n$DBI::errstr\n$DBI::state\n&quot;;<br/>&gt; }<br/>&gt; $drh = DBI-&gt;install_driver(&quot;mysqlPP&quot;);<br/>&gt; $ary_ref = $dbh-&gt;selectcol_arrayref(&quot;SELECT pui,spuid FROM inven WHERE<br/>&gt; dispatchdate=\&quot;0000-00-00\&quot; and dupli is NULL LIMIT 0, 5000&quot;, {<br/>&gt; Columns=&gt;[1,2] });<br/>&gt; %masterdb = @$ary_ref; # build hash from key-value pairs so $hash{$id} =&gt;<br/>&gt; name<br/>&gt; $sth = $dbh-&gt;prepare(&quot;SELECT DISTINCT spuid FROM inven WHERE<br/>&gt; dispatchdate&lt;&gt;\&quot;0000-00-00\&quot; and dupli is NULL LIMIT 0, 1000&quot;);<br/>&gt; $sth-&gt;execute();<br/>&gt; while ( @row = $sth-&gt;fetchrow_array ) {<br/>&gt; push(@dspu, &quot;@row\.dat&quot;);<br/>&gt; }<br/><br/>This code is really bad:<br/><br/>1. It lacks &quot;use strict;&quot; and &quot;use warnings;&quot;.<br/><br/>2. It doesn&#39;t throw an exception when &quot;$dbh&quot; is undef.<br/><br/>3. It is not properly indented.<br/><br/>4. It lacks empty lines between code paragraphs.<br/><br/>Please fix all those. See the link<br/>http://perl-begin.org/tutorials/bad-elements/ on The Perl Beginners Site, which<br/>is a site I maintain.<br/><br/>&gt; <br/>&gt; The above code which uses mysqlPP module is giving our of memory exception<br/>&gt; and not getting executed.<br/><br/>Why are you using mysqlPP instead of https://metacpan.org/release/DBD-mysql ?<br/><br/>&gt; <br/>&gt; Where as if it uses ODBC connection it is working without any exception.<br/>&gt; <br/>&gt; first query will fetch 3000 records and 2nd query fetches 500 records. it<br/>&gt; may increase in later stages.<br/>&gt; <br/>&gt; $dbh = DBI-&gt;connect(&quot;dbi:ODBC:$dsn&quot;, $user, $pw,<br/>&gt; {PrintError =&gt; 1, RaiseError =&gt; 1});<br/>&gt; if (!$dbh) {<br/>&gt; print &quot;error: connection: $DBI::err\n$DBI::errstr\n$DBI::state\n&quot;;<br/>&gt; }<br/>&gt; <br/>&gt; is there any bug in mysqlPP? or am i missing something obvious.<br/>&gt; <br/><br/>There may be.<br/><br/>&gt; Please help in resolving this error.<br/>&gt; <br/>&gt; Regards,<br/>&gt; Ganesh<br/><br/><br/>Regards,<br/><br/> Shlomi Fish<br/><br/><br/>-- <br/>-----------------------------------------------------------------<br/>Shlomi Fish http://www.shlomifish.org/<br/>List of Portability Libraries - http://shlom.in/port-libs<br/><br/>For every A, Chuck Norris is both A and not-A.<br/>Chuck Norris is freaking everything.<br/> &mdash; http://www.shlomifish.org/humour/bits/facts/Chuck-Norris/<br/><br/>Please reply to list if it&#39;s a mailing list post - http://shlom.in/reply .<br/> http://www.nntp.perl.org/group/perl.beginners/2013/05/msg122893.html Sun, 19 May 2013 08:08:49 +0000 DBD::mysqlPP is giving out of memory exception and ODBC is working fine. by Ganesh Babu N $dbh = DBI-&gt;connect(&quot;dbi:mysqlPP:$dsn;host=$host&quot;, $user, $pw,<br/>{PrintError =&gt; 1, RaiseError =&gt; 1});<br/>if (!$dbh) {<br/> print &quot;error: connection: $DBI::err\n$DBI::errstr\n$DBI::state\n&quot;;<br/>}<br/>$drh = DBI-&gt;install_driver(&quot;mysqlPP&quot;);<br/>$ary_ref = $dbh-&gt;selectcol_arrayref(&quot;SELECT pui,spuid FROM inven WHERE<br/>dispatchdate=\&quot;0000-00-00\&quot; and dupli is NULL LIMIT 0, 5000&quot;, {<br/>Columns=&gt;[1,2] });<br/>%masterdb = @$ary_ref; # build hash from key-value pairs so $hash{$id} =&gt;<br/>name<br/>$sth = $dbh-&gt;prepare(&quot;SELECT DISTINCT spuid FROM inven WHERE<br/>dispatchdate&lt;&gt;\&quot;0000-00-00\&quot; and dupli is NULL LIMIT 0, 1000&quot;);<br/>$sth-&gt;execute();<br/>while ( @row = $sth-&gt;fetchrow_array ) {<br/> push(@dspu, &quot;@row\.dat&quot;);<br/>}<br/><br/>The above code which uses mysqlPP module is giving our of memory exception<br/>and not getting executed.<br/><br/>Where as if it uses ODBC connection it is working without any exception.<br/><br/>first query will fetch 3000 records and 2nd query fetches 500 records. it<br/>may increase in later stages.<br/><br/>$dbh = DBI-&gt;connect(&quot;dbi:ODBC:$dsn&quot;, $user, $pw,<br/>{PrintError =&gt; 1, RaiseError =&gt; 1});<br/>if (!$dbh) {<br/> print &quot;error: connection: $DBI::err\n$DBI::errstr\n$DBI::state\n&quot;;<br/>}<br/><br/>is there any bug in mysqlPP? or am i missing something obvious.<br/><br/>Please help in resolving this error.<br/><br/>Regards,<br/>Ganesh<br/><br/> http://www.nntp.perl.org/group/perl.beginners/2013/05/msg122892.html Sat, 18 May 2013 14:41:20 +0000 Re: Tell me how to use CGI.pm in table by Masayoshi Fujimoto I really appreciate the advice you gave me.<br/><br/>On Sat, 18 May 2013 09:18:52 +0100<br/>timothy adigun &lt;2teezperl@gmail.com&gt; wrote:<br/><br/>&gt; Hi Masayoshi,<br/>&gt; <br/>&gt; On Sat, May 18, 2013 at 12:51 AM, Masayoshi Fujimoto &lt;<br/>&gt; m.fujimoto@rocketmail.com&gt; wrote:<br/>&gt; <br/>&gt; &gt; Hi<br/>&gt; &gt; Please help me.<br/>&gt; &gt; I can only see Hilary Duff.<br/>&gt; &gt; I can not see Taylor Momsen.<br/>&gt; &gt; I would like to use table for that.<br/>&gt; &gt; How should I do?<br/>&gt; &gt;<br/>&gt; &gt; ## Here is my script.<br/>&gt; &gt; #!/usr/bin/perl<br/>&gt; &gt; use Modern::Perl;<br/>&gt; &gt; use autodie;<br/>&gt; &gt; use CGI;<br/>&gt; &gt;<br/>&gt; &gt;<br/>&gt; &gt; my $q = CGI-&gt;new;<br/>&gt; &gt;<br/>&gt; &gt; my %label = (<br/>&gt; &gt; celeb =&gt; &#39;Who do you fancy? : &#39;,<br/>&gt; &gt; );<br/>&gt; &gt;<br/>&gt; &gt; my %form = (<br/>&gt; &gt; celeb =&gt; $q-&gt;radio_group(-name=&gt;&#39;celeb&#39;,<br/>&gt; &gt; -values=&gt;[&#39;Hilary<br/>&gt; &gt; Duff&#39;,&#39;Taylor Momsen&#39;],<br/>&gt; &gt; -default=&gt;&#39;Hilary Duff&#39;),<br/>&gt; &gt;<br/>&gt; <br/>&gt; The line above gives a warning message: Odd number of elements in hash<br/>&gt; assignment.<br/>&gt; <br/>&gt; You can re-write that like so:<br/>&gt; <br/>&gt; my $radio = $q-&gt;radio_group(<br/>&gt; -name =&gt; &#39;celeb&#39;,<br/>&gt; -values =&gt; [ &#39;Hilary Duff&#39;, &#39;Taylor Momsen&#39; ],<br/>&gt; -default =&gt; &#39;Hilary Duff&#39;);<br/>&gt; <br/>&gt; my %form = (<br/>&gt; celeb =&gt; $radio,<br/>&gt; submit =&gt; $q-&gt;submit,<br/>&gt; reset =&gt; $q-&gt;reset,<br/>&gt; );<br/>&gt; <br/>&gt; <br/>&gt; &gt; say $q-&gt;header;<br/>&gt; &gt; say $q-&gt;start_html;<br/>&gt; &gt; say $q-&gt;start_form;<br/>&gt; &gt; say $q-&gt;table(<br/>&gt; &gt; $q-&gt;Tr([<br/>&gt; &gt; $q-&gt;td([$label{celeb},$form{celeb}]),<br/>&gt; &gt; $q-&gt;td([$form{submit},$form{reset}]),<br/>&gt; &gt; ])<br/>&gt; &gt; );<br/>&gt; &gt; say $q-&gt;end_form;<br/>&gt; &gt; say $q-&gt;submit;<br/>&gt; &gt; say $q-&gt;end_form;<br/>&gt; &gt; say $q-&gt;end_html;<br/>&gt; &gt;<br/>&gt; &gt;<br/>&gt; &gt; --<br/>&gt; &gt; To unsubscribe, e-mail: beginners-unsubscribe@perl.org<br/>&gt; &gt; For additional commands, e-mail: beginners-help@perl.org<br/>&gt; &gt; http://learn.perl.org/<br/>&gt; &gt;<br/>&gt; &gt;<br/>&gt; &gt;<br/>&gt; <br/>&gt; <br/>&gt; -- <br/>&gt; Tim<br/> http://www.nntp.perl.org/group/perl.beginners/2013/05/msg122891.html Sat, 18 May 2013 12:31:50 +0000 Re: Tell me how to use CGI.pm in table by timothy adigun Hi Masayoshi,<br/><br/>On Sat, May 18, 2013 at 12:51 AM, Masayoshi Fujimoto &lt;<br/>m.fujimoto@rocketmail.com&gt; wrote:<br/><br/>&gt; Hi<br/>&gt; Please help me.<br/>&gt; I can only see Hilary Duff.<br/>&gt; I can not see Taylor Momsen.<br/>&gt; I would like to use table for that.<br/>&gt; How should I do?<br/>&gt;<br/>&gt; ## Here is my script.<br/>&gt; #!/usr/bin/perl<br/>&gt; use Modern::Perl;<br/>&gt; use autodie;<br/>&gt; use CGI;<br/>&gt;<br/>&gt;<br/>&gt; my $q = CGI-&gt;new;<br/>&gt;<br/>&gt; my %label = (<br/>&gt; celeb =&gt; &#39;Who do you fancy? : &#39;,<br/>&gt; );<br/>&gt;<br/>&gt; my %form = (<br/>&gt; celeb =&gt; $q-&gt;radio_group(-name=&gt;&#39;celeb&#39;,<br/>&gt; -values=&gt;[&#39;Hilary<br/>&gt; Duff&#39;,&#39;Taylor Momsen&#39;],<br/>&gt; -default=&gt;&#39;Hilary Duff&#39;),<br/>&gt;<br/><br/> The line above gives a warning message: Odd number of elements in hash<br/>assignment.<br/><br/> You can re-write that like so:<br/><br/> my $radio = $q-&gt;radio_group(<br/> -name =&gt; &#39;celeb&#39;,<br/> -values =&gt; [ &#39;Hilary Duff&#39;, &#39;Taylor Momsen&#39; ],<br/> -default =&gt; &#39;Hilary Duff&#39;);<br/><br/>my %form = (<br/> celeb =&gt; $radio,<br/> submit =&gt; $q-&gt;submit,<br/> reset =&gt; $q-&gt;reset,<br/>);<br/><br/><br/>&gt; say $q-&gt;header;<br/>&gt; say $q-&gt;start_html;<br/>&gt; say $q-&gt;start_form;<br/>&gt; say $q-&gt;table(<br/>&gt; $q-&gt;Tr([<br/>&gt; $q-&gt;td([$label{celeb},$form{celeb}]),<br/>&gt; $q-&gt;td([$form{submit},$form{reset}]),<br/>&gt; ])<br/>&gt; );<br/>&gt; say $q-&gt;end_form;<br/>&gt; say $q-&gt;submit;<br/>&gt; say $q-&gt;end_form;<br/>&gt; say $q-&gt;end_html;<br/>&gt;<br/>&gt;<br/>&gt; --<br/>&gt; To unsubscribe, e-mail: beginners-unsubscribe@perl.org<br/>&gt; For additional commands, e-mail: beginners-help@perl.org<br/>&gt; http://learn.perl.org/<br/>&gt;<br/>&gt;<br/>&gt;<br/><br/><br/>-- <br/>Tim<br/><br/> http://www.nntp.perl.org/group/perl.beginners/2013/05/msg122890.html Sat, 18 May 2013 08:19:07 +0000 Battling with threaded TCP server by Chris Knipe Hi,<br/><br/>I am looking for assistance in programing an TCP Socket server. Effectively,<br/>I am looking for a skeleton to do the following:<br/><br/>- Server starts up, and starts x amounts of threads (working)<br/> - All threads connects to an remote server via TCP and idles, keeping<br/>the connections alive (working)<br/>- Server starts an listening socket using IO::Socket::INET (working)<br/>- Server forks (non-blocking) when an client connects (working)<br/> - Client must now give an command, and that command must be passed to<br/>the thread queues, to be executed by the thread pool as threads becomes<br/>available *whilst the client waits on the socket*.<br/> - The thread will respond with content to the client via the socket<br/> - Client quits<br/><br/>The threads implementation is based on Jerry Hedden&#39;s example of thread<br/>pooling (<br/>http://cpansearch.perl.org/src/JDHEDDEN/threads-1.86/examples/pool_reuse.pl<br/>). The code via term does -exactly- what I require, and I&#39;ve had no issues<br/>what so ever to amend and change this to work as I require it to do over<br/>term. However, I am having significant issues combining this with a socket.<br/>I am absolutely sure however that this is something that I am doing wrong,<br/>more than likely, the entire application needs to be threaded and therefore<br/>re-written from scratch.<br/><br/>The basic theory is that there will be x amount of sleeping threads, and the<br/>socket will receive more connections than what there is threads. The entire<br/>application thus pools connections to retrieve content from remote servers.<br/><br/>My IO::Socket::INET has successfully started and is listening, and I fork<br/>using<br/> print &quot;Server waiting for connections\n&quot;;<br/> my $Client;<br/> while ($Client = $Socket-&gt;accept()) {<br/> my $pid;<br/> while (not defined ($pid = fork())) {<br/> sleep 0.5;<br/> }<br/> if ($pid) {<br/> close($Client);<br/> } else {<br/> $Client-&gt;autoflush(1);<br/> close $Socket;<br/> &amp;DoClientSocket();<br/><br/>And following Jerry&#39;s example code, the threads work by (this is what the<br/>client socket would need to execute as far as I can see):<br/> # Work loop<br/> do {<br/> # Indicate that were are ready to do work<br/> printf(&quot;Idle -&gt; %2d\n&quot;, $tid);<br/> $IDLE_QUEUE-&gt;enqueue($tid);<br/><br/> # Wait for work from the queue<br/> my $work = $work_q-&gt;dequeue();<br/><br/> # If no more work, exit<br/> last if ($work &lt; 0);<br/><br/> # Do some work while monitoring $TERM<br/> printf(&quot; %2d &lt;- Working\n&quot;, $tid);<br/> while (($work &gt; 0) &amp;&amp; ! $TERM) {<br/> $work -= sleep($work);<br/> }<br/><br/> # Loop back to idle state if not told to terminate<br/> } while (! $TERM);<br/><br/>But I am really at a loss as to how to integrate the two. The sub used by<br/>IO::Socket::INET (even if passing the variables and hash refs as parameters,<br/>i.e. &amp;ClientSocket(\%work_queues, $tid)) does not successfully pass any work<br/>to the thread pool, and the thread pool also seems to be &#39;idling&#39; rather<br/>than checking and processing work given to it. I believe this is because<br/>IO::Socket::INET waits for client connections, and does not give the thread<br/>pool time to look for and do it&#39;s queued work as well.<br/><br/>Can anyone please assist a semi newbie? I need this to work relatively<br/>urgently and I would prefer to rather take this off list and spend half an<br/>hour or an hour with an individual able to assist (just don&#39;t want to sit<br/>here spamming the lists). At this stage, I&#39;m even willing to pay if that&#39;s<br/>what it needs to come down to...<br/><br/>Many thanks,<br/>Chris.<br/><br/><br/><br/> http://www.nntp.perl.org/group/perl.beginners/2013/05/msg122889.html Sat, 18 May 2013 07:53:56 +0000 Re: What does $$ mean ? by *Shaji Kalidasan* Dr. Ruud,<br/><br/>Thank you very much for your kind explanation. The pointers you suggested is very handy in understanding the complex data structures.<br/><br/>&nbsp;<br/>best,<br/>Shaji <br/>-------------------------------------------------------------------------------<br/>Your talent is God&#39;s gift to you. What you do with it is your gift back to God.<br/>-------------------------------------------------------------------------------<br/><br/><br/>________________________________<br/> From: Dr.Ruud &lt;rvtol+usenet@isolution.nl&gt;<br/>To: beginners@perl.org <br/>Sent: Friday, 17 May 2013 6:17 PM<br/>Subject: Re: What does $$ mean ?<br/> <br/><br/>On 17/05/2013 14:39, *Shaji Kalidasan* wrote:<br/><br/>&gt; [CODE1]<br/>&gt; keys %{$$disk_type_ref{$pool}};<br/>&gt; [/CODE1]<br/>&gt;<br/>&gt; Moreover, what does $$ mean here<br/><br/>&nbsp; %{$$disk_type_ref{$pool}};<br/><br/>can also be written as<br/><br/>&nbsp; %{ $disk_type_ref-&gt;{ $pool } };<br/><br/>See further perldsc.<br/><br/>&gt; -------------------------------------------------------------------------------<br/>&gt; Your talent is God&#39;s gift to you. What you do with it is your gift back<br/>&gt; to God.<br/>&gt; -------------------------------------------------------------------------------<br/><br/>https://www.facebook.com/pages/David-Bowie-is-GOD/133491090062327<br/><br/>-- <br/>Ruud<br/><br/><br/>-- <br/>To unsubscribe, e-mail: beginners-unsubscribe@perl.org<br/>For additional commands, e-mail: beginners-help@perl.org<br/>http://learn.perl.org/<br/> http://www.nntp.perl.org/group/perl.beginners/2013/05/msg122888.html Sat, 18 May 2013 04:53:04 +0000 Tell me how to use CGI.pm in table by Masayoshi Fujimoto Hi<br/>Please help me.<br/>I can only see Hilary Duff.<br/>I can not see Taylor Momsen.<br/>I would like to use table for that.<br/>How should I do?<br/><br/>## Here is my script.<br/>#!/usr/bin/perl<br/>use Modern::Perl;<br/>use autodie;<br/>use CGI;<br/><br/><br/>my $q = CGI-&gt;new;<br/><br/>my %label = (<br/> celeb =&gt; &#39;Who do you fancy? : &#39;,<br/> );<br/> <br/>my %form = ( <br/> celeb =&gt; $q-&gt;radio_group(-name=&gt;&#39;celeb&#39;,<br/> -values=&gt;[&#39;Hilary Duff&#39;,&#39;Taylor Momsen&#39;],<br/> -default=&gt;&#39;Hilary Duff&#39;),<br/> submit =&gt; $q-&gt;submit,<br/> reset =&gt; $q-&gt;reset,<br/> ); <br/><br/>say $q-&gt;header;<br/>say $q-&gt;start_html;<br/>say $q-&gt;start_form;<br/>say $q-&gt;table(<br/> $q-&gt;Tr([<br/> $q-&gt;td([$label{celeb},$form{celeb}]),<br/> $q-&gt;td([$form{submit},$form{reset}]), <br/> ])<br/> ); <br/>say $q-&gt;end_form;<br/>say $q-&gt;submit;<br/>say $q-&gt;end_form;<br/>say $q-&gt;end_html;<br/><br/> http://www.nntp.perl.org/group/perl.beginners/2013/05/msg122887.html Fri, 17 May 2013 23:51:40 +0000 RE: What does $$ mean ? by Frank K. Gosh, I always thought &quot;$$&quot; is what you have to pay when you get a divorce &lt;vbg&gt;.. flk k<br/><br/>-----Original Message-----<br/>From: Dr.Ruud [mailto:rvtol+usenet@isolution.nl] <br/>Sent: Friday, May 17, 2013 7:47 AM<br/>To: beginners@perl.org<br/>Subject: Re: What does $$ mean ?<br/><br/>On 17/05/2013 14:39, *Shaji Kalidasan* wrote:<br/><br/>&gt; [CODE1]<br/>&gt; keys %{$$disk_type_ref{$pool}};<br/>&gt; [/CODE1]<br/>&gt;<br/>&gt; Moreover, what does $$ mean here<br/><br/> %{$$disk_type_ref{$pool}};<br/><br/>can also be written as<br/><br/> %{ $disk_type_ref-&gt;{ $pool } };<br/><br/>See further perldsc.<br/><br/>&gt; ----------------------------------------------------------------------<br/>&gt; --------- Your talent is God&#39;s gift to you. What you do with it is <br/>&gt; your gift back to God.<br/>&gt; ----------------------------------------------------------------------<br/>&gt; ---------<br/><br/>https://www.facebook.com/pages/David-Bowie-is-GOD/133491090062327<br/><br/>--<br/>Ruud<br/><br/><br/>-- <br/>To unsubscribe, e-mail: beginners-unsubscribe@perl.org<br/>For additional commands, e-mail: beginners-help@perl.org<br/>http://learn.perl.org/<br/><br/><br/><br/> http://www.nntp.perl.org/group/perl.beginners/2013/05/msg122886.html Fri, 17 May 2013 14:03:23 +0000 Re: What does $$ mean ? by Dr.Ruud On 17/05/2013 14:39, *Shaji Kalidasan* wrote:<br/><br/>&gt; [CODE1]<br/>&gt; keys %{$$disk_type_ref{$pool}};<br/>&gt; [/CODE1]<br/>&gt;<br/>&gt; Moreover, what does $$ mean here<br/><br/> %{$$disk_type_ref{$pool}};<br/><br/>can also be written as<br/><br/> %{ $disk_type_ref-&gt;{ $pool } };<br/><br/>See further perldsc.<br/><br/>&gt; -------------------------------------------------------------------------------<br/>&gt; Your talent is God&#39;s gift to you. What you do with it is your gift back<br/>&gt; to God.<br/>&gt; -------------------------------------------------------------------------------<br/><br/>https://www.facebook.com/pages/David-Bowie-is-GOD/133491090062327<br/><br/>-- <br/>Ruud<br/><br/> http://www.nntp.perl.org/group/perl.beginners/2013/05/msg122885.html Fri, 17 May 2013 12:47:31 +0000 What does $$ mean ? by *Shaji Kalidasan* Greetings,<br/><br/>What does this mean<br/><br/>[CODE1]<br/><br/>keys %{$$disk_type_ref{$pool}};<br/>[/CODE1]<br/><br/><br/>Moreover, what does $$ mean here<br/><br/>[CODE2]<br/><br/>@{$$disk_type_ref{$pool}{$med_value}}<br/>[/CODE2]<br/><br/><br/>What data structures does the above things denote? Any pointers will be of great help.<br/><br/>Thanking you in advance.<br/><br/>best,<br/><br/>Shaji <br/>-------------------------------------------------------------------------------<br/>Your talent is God&#39;s gift to you. What you do with it is your gift back to God.<br/>-------------------------------------------------------------------------------<br/> http://www.nntp.perl.org/group/perl.beginners/2013/05/msg122884.html Fri, 17 May 2013 12:39:27 +0000 Re: map problems by Natxo Asenjo On Thu, May 16, 2013 at 11:14 PM, Jim Gibson &lt;jimsgibson@gmail.com&gt; wrote:<br/><br/>&gt; The * in (.*) is &quot;greedy&quot;, meaning the Perl regular expression engine will<br/>&gt; try to match as much as possible in each string after it finds the<br/>&gt; substring &#39;cn=&#39;. To make it &quot;non-greedy&quot;, put a question mark after the<br/>&gt; quantifier: s/^cn=(.*?),/$1/<br/>&gt;<br/>&gt;<br/>yes, I had forgotten that. Thanks for your kind explanation.<br/><br/>-- <br/>groet,<br/>natxo<br/><br/> http://www.nntp.perl.org/group/perl.beginners/2013/05/msg122883.html Thu, 16 May 2013 21:32:13 +0000 Re: map problems by Peter Gordon &lt;HTML&gt;&lt;HEAD&gt;<br/>&lt;BASEFONT FACE=&quot;Arial&quot; SIZE=&quot;3&quot; COLOR=&quot;#000000&quot;&gt;<br/>&lt;/HEAD&gt;<br/>&lt;BODY&gt;<br/>&lt;div&gt;On Thu, 16 May 2013 21:57:55 +0200, Natxo Asenjo wrote:&lt;br&gt;&lt;/div&gt;<br/>&lt;div&gt;&amp;gt;in a ldap script where I get a list of values of a multivalued &amp;gt;attribute like this:&lt;br&gt;&lt;/div&gt;<br/>&lt;div&gt;&amp;nbsp;&lt;/div&gt;<br/>&lt;div&gt;&amp;gt;@memberof = qw( cn=group1,cn=xxx,dc=domain,dc=tld &amp;gt;cn=group2,cn=xxx,d=domain,dc=tld etc etc) ;&lt;br&gt;&lt;/div&gt;<br/>&lt;div&gt;&amp;nbsp;&lt;/div&gt;<br/>&lt;div&gt;&amp;gt;I would like to use map to convert the list of elements to&lt;br&gt;&lt;/div&gt;<br/>&lt;div&gt;&amp;gt;@memberof = qw( group1 group2 group3 etc etc )&lt;br&gt;&lt;/div&gt;<br/>&lt;div&gt;&lt;br&gt;<br/>I&#39;m not clear on what you are trying to achieve.&amp;nbsp; Your problem is probably in the RE.&amp;nbsp; The comma in your RE is greedy. &lt;br&gt;&lt;/div&gt;<br/>&lt;div&gt;A &amp;quot;?&amp;quot; within the brackets makes it non greedy.&amp;nbsp; Read&lt;br&gt;&lt;/div&gt;<br/>&lt;div&gt;&lt;a href=&quot;http://www.itworld.com/nl/perl/01112001&quot;&gt;http://www.itworld.com/nl/perl/01112001&lt;/a&gt;&lt;br&gt;&lt;/div&gt;<br/>&lt;div&gt;for a good explanation of this subject.&lt;br&gt;&lt;/div&gt;<br/>&lt;div&gt;The code below illustrates the difference.&lt;br&gt;&lt;/div&gt;<br/>&lt;div&gt;&amp;nbsp;&lt;/div&gt;<br/>&lt;div&gt;#!/usr/bin/perl -w&lt;br&gt;&lt;/div&gt;<br/>&lt;div&gt;use 5.14.0;&lt;br&gt;&lt;/div&gt;<br/>&lt;div&gt;my $str = &amp;quot;cn=group1,cn=xxx,dc=domain,dc=tld cn=group2,cn=xxx,d=domain,dc=tld&amp;quot;;&lt;br&gt;&lt;/div&gt;<br/>&lt;div&gt;$str =~ /^cn=(.*),.*/;&lt;br&gt;&lt;/div&gt;<br/>&lt;div&gt;say $1;&lt;br&gt;&lt;/div&gt;<br/>&lt;div&gt;$str =~ /^cn=(.*?),.*/;&lt;br&gt;&lt;/div&gt;<br/>&lt;div&gt;say $1;&lt;br&gt;&lt;/div&gt;<br/>&lt;div&gt;__END__&lt;br&gt;&lt;/div&gt;<br/>&lt;div&gt;*** Output ***&lt;br&gt;&lt;/div&gt;<br/>&lt;div&gt;group1,cn=xxx,dc=domain,dc=tld cn=group2,cn=xxx,d=domain&lt;br&gt;&lt;/div&gt;<br/>&lt;div&gt;group1&lt;br&gt;<br/>&lt;br&gt;<br/>&lt;br&gt;&lt;/div&gt;<br/>&lt;div&gt;-- &lt;br&gt;&lt;/div&gt;<br/>&lt;div&gt;Peter Gordon, petergo@netspace.net.au on 05/17/2013&lt;br&gt;&lt;/div&gt;<br/>&lt;/body&gt;&lt;/html&gt;<br/><br/><br/> http://www.nntp.perl.org/group/perl.beginners/2013/05/msg122882.html Thu, 16 May 2013 21:28:18 +0000 Re: map problems by timothy adigun Hi Natxo,<br/>Please see my comment below:<br/><br/>On Thu, May 16, 2013 at 8:57 PM, Natxo Asenjo &lt;natxo.asenjo@gmail.com&gt;wrote:<br/><br/>&gt; hi,<br/>&gt;<br/>&gt; in a ldap script where I get a list of values of a multivalued attribute<br/>&gt; like this:<br/>&gt;<br/>&gt; @memberof = qw( cn=group1,cn=xxx,dc=domain,dc=tld<br/>&gt; cn=group2,cn=xxx,d=domain,dc=tld etc etc) ;<br/>&gt;<br/><br/> Since you use &quot;qw&quot;, there is no need to still separate the element of<br/>your array with comma.<br/><br/>&gt;<br/>&gt; I would like to use map to convert the list of elements to<br/>&gt; @memberof = qw( group1 group2 group3 etc etc )<br/>&gt;<br/><br/> Does etc etc here mean words like group...?<br/><br/><br/>&gt;<br/>&gt; This is the code I have tried to capture the first string after the first<br/>&gt; &#39;=&#39; in the $1 variable<br/>&gt;<br/>&gt; @memberof = map { s/^cn=(.*),.*$/$1/g; $_ } @memberof;<br/>&gt; for ( @memberof ) {<br/>&gt; print &quot;[$_]&quot; . &quot; &quot; ;<br/>&gt; }<br/>&gt;<br/>&gt; but this snippet strangely cuts the start and the end of every array<br/>&gt; element beginning and end so I get this:<br/>&gt;<br/>&gt; [group1,cn=xxx,dc=domain] [group2,cn=xxxx,dc=domain]<br/>&gt;<br/>&gt; so it is obviously not working. Is there a way to do this with map or do I<br/>&gt; just have to process the array in a for loop and fill a new array with the<br/>&gt; values? Just curious<br/>&gt;<br/><br/><br/> Understanding for/foreach loop could help in a way to understand and<br/>use map function.<br/><br/> Please see below one of the way of doing what you intended:<br/><br/> [CODE]<br/><br/> use warnings;<br/> use strict;<br/><br/>my @memberof =<br/> qw( cn=group1 cn=xxx dc=domain dc=tld cn=group2 cn=xxx d=domain dc=tld<br/>etc etc);<br/><br/> ## using for loop<br/><br/>for my $grp (@memberof) {<br/> if ( $grp =~ m/(?&lt;=\=)(.+)/ ) {<br/> my $matched = $1;<br/> print $matched, $/ if $matched =~ /group/;<br/> }<br/>}<br/><br/>## use map function<br/><br/>@memberof = map {<br/> if (/(?&lt;=\=)(.+)/) {<br/> my $matched = $1;<br/> $matched, $/ if $matched =~ /group/;<br/> }<br/>} @memberof;<br/><br/>print @memberof;<br/><br/> [/CODE]<br/><br/> Hope this helps.<br/><br/>&gt;<br/>&gt; TIA,<br/>&gt; --<br/>&gt; Groeten,<br/>&gt; natxo<br/>&gt;<br/><br/><br/><br/>-- <br/>Tim<br/><br/> http://www.nntp.perl.org/group/perl.beginners/2013/05/msg122881.html Thu, 16 May 2013 21:27:21 +0000 Re: map problems by Jim Gibson <br/>On May 16, 2013, at 12:57 PM, Natxo Asenjo wrote:<br/><br/>&gt; hi,<br/>&gt; <br/>&gt; in a ldap script where I get a list of values of a multivalued attribute like this:<br/>&gt; <br/>&gt; @memberof = qw( cn=group1,cn=xxx,dc=domain,dc=tld cn=group2,cn=xxx,d=domain,dc=tld etc etc) ;<br/>&gt; <br/>&gt; I would like to use map to convert the list of elements to <br/>&gt; @memberof = qw( group1 group2 group3 etc etc )<br/>&gt; <br/>&gt; This is the code I have tried to capture the first string after the first &#39;=&#39; in the $1 variable<br/>&gt; <br/>&gt; @memberof = map { s/^cn=(.*),.*$/$1/g; $_ } @memberof;<br/>&gt; for ( @memberof ) {<br/>&gt; print &quot;[$_]&quot; . &quot; &quot; ;<br/>&gt; }<br/>&gt; <br/>&gt; but this snippet strangely cuts the start and the end of every array element beginning and end so I get this:<br/>&gt; <br/>&gt; [group1,cn=xxx,dc=domain] [group2,cn=xxxx,dc=domain]<br/>&gt; <br/>&gt; so it is obviously not working. Is there a way to do this with map or do I just have to process the array in a for loop and fill a new array with the values? Just curious <br/><br/>The * in (.*) is &quot;greedy&quot;, meaning the Perl regular expression engine will try to match as much as possible in each string after it finds the substring &#39;cn=&#39;. To make it &quot;non-greedy&quot;, put a question mark after the quantifier: s/^cn=(.*?),/$1/<br/><br/>Note that the &#39;.*$&#39; characters ending your pattern are completely superfluous and will not affect the match or substitution in any way.<br/><br/>Another way to achieve the same results is to match all non-comma characters up to the first comma: s/^cn=([^,]*),/$1/<br/><br/>Also note that since $_ inside the map block is an alias to the array members, you are modifying the array members in place, and you do not need to assign the result to the original array. Since using map in void context can be confusing, many Perl programmers would write it this way:<br/><br/> s/^cn=([^,]*),/$1/ for @memberof;<br/><br/>Since I wouldn&#39;t normally want to modify the original array, I might do it this way, taking advantage of the fact that the match operator (m//) in list context returns a list of the captured matches, so no substitution is required:<br/><br/>my @newmemberof = map { m/^cn=([^,]*),/g } @memberof;<br/><br/> http://www.nntp.perl.org/group/perl.beginners/2013/05/msg122880.html Thu, 16 May 2013 21:14:47 +0000 map problems by Natxo Asenjo hi,<br/><br/>in a ldap script where I get a list of values of a multivalued attribute<br/>like this:<br/><br/>@memberof = qw( cn=group1,cn=xxx,dc=domain,dc=tld<br/>cn=group2,cn=xxx,d=domain,dc=tld etc etc) ;<br/><br/>I would like to use map to convert the list of elements to<br/>@memberof = qw( group1 group2 group3 etc etc )<br/><br/>This is the code I have tried to capture the first string after the first<br/>&#39;=&#39; in the $1 variable<br/><br/>@memberof = map { s/^cn=(.*),.*$/$1/g; $_ } @memberof;<br/> for ( @memberof ) {<br/> print &quot;[$_]&quot; . &quot; &quot; ;<br/> }<br/><br/>but this snippet strangely cuts the start and the end of every array<br/>element beginning and end so I get this:<br/><br/>[group1,cn=xxx,dc=domain] [group2,cn=xxxx,dc=domain]<br/><br/>so it is obviously not working. Is there a way to do this with map or do I<br/>just have to process the array in a for loop and fill a new array with the<br/>values? Just curious<br/><br/>TIA,<br/>--<br/>Groeten,<br/>natxo<br/><br/> http://www.nntp.perl.org/group/perl.beginners/2013/05/msg122879.html Thu, 16 May 2013 19:58:11 +0000 Re: what's the problem with a system call by Manuel Reimer Shlomi Fish wrote:<br/>&gt; What system() does (at least on UNIX-like OSes) is fork a child, call exec()<br/>&gt; with a new process and wait for the new child to terminate (plus some other<br/>&gt; stuff to get rid of misbehaviours).<br/><br/>... and if you call &quot;system&quot; with just one long string, then Perl opens the <br/>system default shell between your script and the external application, you <br/>wanted to start.<br/><br/>So wherever possible you should prefer to use:<br/><br/>system(&#39;somecommand&#39;, &#39;--param1=somevalue&#39;, &#39;--anotherparam&#39;);<br/><br/>and not:<br/><br/>system(&#39;somecommand --param1=somevalue --anotherparam&#39;);<br/><br/>The first one opens *two* processes (the shell and &quot;somecommand&quot;) while the <br/>second only opens one process and passes the arguments directly without any <br/>shell in between.<br/><br/>Yours<br/><br/>Manuel<br/><br/> http://www.nntp.perl.org/group/perl.beginners/2013/05/msg122878.html Thu, 16 May 2013 15:50:18 +0000 Re: Spreadsheet::WriteExcel - multi-coloured text in cells by Dr.Ruud On 15/05/2013 21:35, David Precious wrote:<br/>&gt; On Wed, 15 May 2013 10:34:02 +0100<br/>&gt; Gary Stainburn &lt;gary.stainburn@ringways.co.uk&gt; wrote:<br/><br/>&gt;&gt; Is it possible to write text cells where part of the string is<br/>&gt;&gt; highlighted in red? If so, how can I do it?<br/>&gt;<br/>&gt; I&#39;m fairly sure the format of a cell applies to the whole content of<br/>&gt; that cell - can you do what you&#39;re asking for in Excel or similar<br/>&gt; yourself? If not, then I very much doubt you can do it via<br/>&gt; Spreadsheet::WriteExcel.<br/><br/>There is cell formatting and there is text formatting.<br/>Each character can basically have its own background-color, <br/>foreground-color, font, font-weight, etc.<br/><br/>And beyond that, each cell can contain an object, like a Word-document.<br/>But you don&#39;t need to go there to achieve what you want.<br/><br/>First find out how you would do it in its internal language (VB?),<br/>and then port that.<br/><br/>-- <br/>Ruud<br/><br/> http://www.nntp.perl.org/group/perl.beginners/2013/05/msg122877.html Thu, 16 May 2013 11:27:33 +0000 Re: module versions by shawn wilson On Wed, May 15, 2013 at 4:13 PM, Ron Bergin &lt;rkb@i.frys.com&gt; wrote:<br/>&gt; shawn wilson wrote:<br/>&gt;&gt; I asked this in #perl-help and was told that by the time perl checked<br/>&gt;&gt; the version, the module was already loaded - is there a way to check<br/>&gt;&gt; the version without completely loading the module so that when one<br/>&gt;&gt; failed, I could move on to another module of the same name whose<br/>&gt;&gt; version might succeed?<br/>&gt;&gt;<br/>&gt;<br/>&gt; Why not specify the minimum version number that your script requires in<br/>&gt; the use statement? If that version is not available, then what&#39;s the<br/>&gt; point of going forward?<br/>&gt;<br/><br/>See my test case - I do have a minimum version. The point in going<br/>forward is that the minimum version IS met further along the path.<br/><br/>&gt; If you don&#39;t want to do that, then you could use Module::Load::Conditional<br/>&gt; to test if the desired version is loadable.<br/>&gt;<br/>&gt; http://search.cpan.org/~bingos/Module-Load-Conditional-0.54/lib/Module/Load/Conditional.pm<br/>&gt;<br/><br/>That module might work if I manually cycle through single paths in<br/>@INC and test. Though I&#39;m not sure about the side effects of doing<br/>this might be?<br/> http://www.nntp.perl.org/group/perl.beginners/2013/05/msg122876.html Wed, 15 May 2013 20:47:50 +0000 Re: module versions by Ron Bergin shawn wilson wrote:<br/>&gt; I asked this in #perl-help and was told that by the time perl checked<br/>&gt; the version, the module was already loaded - is there a way to check<br/>&gt; the version without completely loading the module so that when one<br/>&gt; failed, I could move on to another module of the same name whose<br/>&gt; version might succeed?<br/>&gt;<br/><br/>Why not specify the minimum version number that your script requires in<br/>the use statement? If that version is not available, then what&#39;s the<br/>point of going forward?<br/><br/>If you don&#39;t want to do that, then you could use Module::Load::Conditional<br/>to test if the desired version is loadable.<br/><br/>http://search.cpan.org/~bingos/Module-Load-Conditional-0.54/lib/Module/Load/Conditional.pm<br/><br/>-- <br/>Ron Bergin<br/><br/><br/><br/> http://www.nntp.perl.org/group/perl.beginners/2013/05/msg122875.html Wed, 15 May 2013 20:13:54 +0000 Re: module versions by Peter Eztta How about using ExtUtils::MakeMaker or Module::Build and checking for the required version at build time?<br/><br/>I suppose this doesn&#39;t address the desire to use a different version if the one you&#39;re looking for isn&#39;t present though...<br/><br/>Regards,<br/><br/>Peter H. Ezetta<br/><br/>On Wed, May 15, 2013 at 12:55:25PM -0700, shawn wilson wrote:<br/>&gt; On Wed, May 15, 2013 at 3:28 PM, Octavian Rasnita &lt;orasnita@gmail.com&gt; wrote:<br/>&gt; &gt; From: &quot;shawn wilson&quot; &lt;ag4ve.us@gmail.com&gt;<br/>&gt; &gt;<br/>&gt; &gt;<br/>&gt; &gt;<br/>&gt; &gt;&gt; I asked this in #perl-help and was told that by the time perl checked<br/>&gt; &gt;&gt; the version, the module was already loaded - is there a way to check<br/>&gt; &gt;&gt; the version without completely loading the module so that when one<br/>&gt; &gt;&gt; failed, I could move on to another module of the same name whose<br/>&gt; &gt;&gt; version might succeed?<br/>&gt; &gt;&gt;<br/>&gt; &gt;&gt; I attached a tar file with a test, let me know if nothing is seen.<br/>&gt; &gt;&gt;<br/>&gt; &gt;<br/>&gt;<br/>&gt; &gt;<br/>&gt; &gt; This check is usually done at development time.<br/>&gt; &gt; Is there a reason you can&#39;t check which version of the modules you need are<br/>&gt; &gt; working with your code when you create the app?<br/>&gt; &gt;<br/>&gt;<br/>&gt; No, I suppose i can just do perl -Ilib for development and the like.<br/>&gt; However, not checking that there is a satisfactory module version<br/>&gt; anywhere along the namespace seems to make things more brittle than<br/>&gt; they nead to be (and it&#39;s annoying me :) ).<br/>&gt;<br/>&gt; --<br/>&gt; To unsubscribe, e-mail: beginners-unsubscribe@perl.org<br/>&gt; For additional commands, e-mail: beginners-help@perl.org<br/>&gt; http://learn.perl.org/<br/>&gt;<br/>&gt;<br/><br/>Confidentiality Notice: This e-mail may contain proprietary information some of which may be legally privileged. It is for the intended recipient(s) only. If you believe that it has been sent to you in error, please notify the sender by reply e-mail and delete the message. Any disclosure, copying, distribution or use of this information by someone other than the intended recipient(s) is prohibited and may be unlawful.<br/> http://www.nntp.perl.org/group/perl.beginners/2013/05/msg122874.html Wed, 15 May 2013 20:00:44 +0000 Re: module versions by shawn wilson On Wed, May 15, 2013 at 3:28 PM, Octavian Rasnita &lt;orasnita@gmail.com&gt; wrote:<br/>&gt; From: &quot;shawn wilson&quot; &lt;ag4ve.us@gmail.com&gt;<br/>&gt;<br/>&gt;<br/>&gt;<br/>&gt;&gt; I asked this in #perl-help and was told that by the time perl checked<br/>&gt;&gt; the version, the module was already loaded - is there a way to check<br/>&gt;&gt; the version without completely loading the module so that when one<br/>&gt;&gt; failed, I could move on to another module of the same name whose<br/>&gt;&gt; version might succeed?<br/>&gt;&gt;<br/>&gt;&gt; I attached a tar file with a test, let me know if nothing is seen.<br/>&gt;&gt;<br/>&gt;<br/><br/>&gt;<br/>&gt; This check is usually done at development time.<br/>&gt; Is there a reason you can&#39;t check which version of the modules you need are<br/>&gt; working with your code when you create the app?<br/>&gt;<br/><br/>No, I suppose i can just do perl -Ilib for development and the like.<br/>However, not checking that there is a satisfactory module version<br/>anywhere along the namespace seems to make things more brittle than<br/>they nead to be (and it&#39;s annoying me :) ).<br/> http://www.nntp.perl.org/group/perl.beginners/2013/05/msg122873.html Wed, 15 May 2013 19:55:59 +0000 Re: Spreadsheet::WriteExcel - multi-coloured text in cells by David Precious On Wed, 15 May 2013 10:34:02 +0100<br/>Gary Stainburn &lt;gary.stainburn@ringways.co.uk&gt; wrote:<br/><br/>&gt; Is it possible to write text cells where part of the string is<br/>&gt; highlighted in red? If so, how can I do it?<br/><br/>I&#39;m fairly sure the format of a cell applies to the whole content of<br/>that cell - can you do what you&#39;re asking for in Excel or similar<br/>yourself? If not, then I very much doubt you can do it via<br/>Spreadsheet::WriteExcel.<br/><br/><br/><br/>-- <br/>David Precious (&quot;bigpresh&quot;) &lt;davidp@preshweb.co.uk&gt;<br/>http://www.preshweb.co.uk/ www.preshweb.co.uk/twitter<br/>www.preshweb.co.uk/linkedin www.preshweb.co.uk/facebook<br/>www.preshweb.co.uk/cpan www.preshweb.co.uk/github<br/><br/><br/> http://www.nntp.perl.org/group/perl.beginners/2013/05/msg122872.html Wed, 15 May 2013 19:35:33 +0000 Re: module versions by Octavian Rasnita From: &quot;shawn wilson&quot; &lt;ag4ve.us@gmail.com&gt;<br/><br/><br/>&gt;I asked this in #perl-help and was told that by the time perl checked<br/>&gt; the version, the module was already loaded - is there a way to check<br/>&gt; the version without completely loading the module so that when one<br/>&gt; failed, I could move on to another module of the same name whose<br/>&gt; version might succeed?<br/>&gt;<br/>&gt; I attached a tar file with a test, let me know if nothing is seen.<br/>&gt;<br/><br/><br/>--------------------------------------------------------------------------------<br/><br/><br/>&gt; -- <br/><br/><br/><br/>This check is usually done at development time.<br/>Is there a reason you can&#39;t check which version of the modules you need are <br/>working with your code when you create the app?<br/><br/>Octavian<br/><br/> http://www.nntp.perl.org/group/perl.beginners/2013/05/msg122871.html Wed, 15 May 2013 19:29:12 +0000 module versions by shawn wilson I asked this in #perl-help and was told that by the time perl checked<br/>the version, the module was already loaded - is there a way to check<br/>the version without completely loading the module so that when one<br/>failed, I could move on to another module of the same name whose<br/>version might succeed?<br/><br/>I attached a tar file with a test, let me know if nothing is seen.<br/><br/> http://www.nntp.perl.org/group/perl.beginners/2013/05/msg122870.html Wed, 15 May 2013 15:57:30 +0000 Spreadsheet::WriteExcel - multi-coloured text in cells by Gary Stainburn Hi folks<br/><br/>Is it possible to write text cells where part of the string is highlighted in <br/>red? If so, how can I do it?<br/><br/>Gary<br/> http://www.nntp.perl.org/group/perl.beginners/2013/05/msg122869.html Wed, 15 May 2013 09:34:24 +0000 Re: How do I update CPAN? by Peter Eztta From within the CPAN shell (i.e. issue the cpan command from the commandline) issue the two commands listed below:<br/><br/>install CPAN<br/><br/>Once that&#39;s done<br/><br/>reload CPAN<br/><br/>The rest should happen automagically for you.<br/><br/>Thanks,<br/><br/>Peter H. Ezetta<br/><br/>On Tue, May 14, 2013 at 03:05:59PM -0700, Sherman Willden wrote:<br/>&gt; I received the below message. Now what? I am not familiar with install.<br/>&gt;<br/>&gt; Thank you;<br/>&gt;<br/>&gt; Sherman<br/>&gt;<br/>&gt; Fetching with HTTP::Tiny:<br/>&gt; http://httpupdate35.cpanel.net/CPAN/modules/02packages.details.txt.gz<br/>&gt; Reading &#39;/home/sherman/.cpan/sources/modules/02packages.details.txt.gz&#39;<br/>&gt; Database was generated on Tue, 14 May 2013 21:41:05 GMT<br/>&gt; HTTP::Date not available<br/>&gt; ..............<br/>&gt; New CPAN.pm version (v2.00) available.<br/>&gt; [Currently running version is v1.9800]<br/>&gt; You might want to try<br/>&gt; install CPAN<br/>&gt; reload cpan<br/>&gt; to both upgrade CPAN.pm and run the new version without leaving<br/>&gt; the current session.<br/><br/>Confidentiality Notice: This e-mail may contain proprietary information some of which may be legally privileged. It is for the intended recipient(s) only. If you believe that it has been sent to you in error, please notify the sender by reply e-mail and delete the message. Any disclosure, copying, distribution or use of this information by someone other than the intended recipient(s) is prohibited and may be unlawful.<br/> http://www.nntp.perl.org/group/perl.beginners/2013/05/msg122868.html Tue, 14 May 2013 22:13:31 +0000 How do I update CPAN? by Sherman Willden I received the below message. Now what? I am not familiar with install.<br/><br/>Thank you;<br/><br/>Sherman<br/><br/>Fetching with HTTP::Tiny:<br/>http://httpupdate35.cpanel.net/CPAN/modules/02packages.details.txt.gz<br/>Reading &#39;/home/sherman/.cpan/sources/modules/02packages.details.txt.gz&#39;<br/> Database was generated on Tue, 14 May 2013 21:41:05 GMT<br/> HTTP::Date not available<br/>..............<br/> New CPAN.pm version (v2.00) available.<br/> [Currently running version is v1.9800]<br/> You might want to try<br/> install CPAN<br/> reload cpan<br/> to both upgrade CPAN.pm and run the new version without leaving<br/> the current session.<br/><br/> http://www.nntp.perl.org/group/perl.beginners/2013/05/msg122867.html Tue, 14 May 2013 22:06:11 +0000 Re: what's the problem with a system call by Shlomi Fish Hi xiaolan,<br/><br/>On Tue, 14 May 2013 18:51:51 +0800<br/>xiaolan &lt;practicalperl@gmail.com&gt; wrote:<br/><br/>&gt; Thanks all the answers.<br/>&gt; Shlomi long time no see :)<br/><br/>Yes. :-) I am available on IM:<br/><br/>http://www.shlomifish.org/me/contact-me/<br/><br/>&gt; <br/>&gt; Have another question that, what&#39;s the difference between the system call<br/>&gt; child process and the native forked child process?<br/>&gt; Does the child process of system call have the problems of receiving<br/>&gt; signals from the parent?<br/><br/>What system() does (at least on UNIX-like OSes) is fork a child, call exec()<br/>with a new process and wait for the new child to terminate (plus some other<br/>stuff to get rid of misbehaviours). A child process can still get a signal from<br/>every process of that user or that belongs to the user root (including the<br/>parent process, but not exclusively).<br/><br/>Regards,<br/><br/> Shlomi Fish<br/><br/>&gt; <br/>&gt; <br/>&gt; <br/>&gt; <br/>&gt; On Tue, May 14, 2013 at 5:16 PM, Shlomi Fish &lt;shlomif@shlomifish.org&gt; wrote:<br/>&gt; <br/>&gt; &gt; Hi Brian,<br/>&gt; &gt;<br/>&gt; &gt; thanks for replying well to xiaolan&rsquo;s question.<br/>&gt; &gt;<br/>&gt; &gt; Regards,<br/>&gt; &gt;<br/>&gt; &gt; Shlomi Fish<br/>&gt; &gt;<br/>&gt; &gt; --<br/>&gt; &gt; -----------------------------------------------------------------<br/>&gt; &gt; Shlomi Fish http://www.shlomifish.org/<br/>&gt; &gt; My Public Domain Photos - http://www.flickr.com/photos/shlomif/<br/>&gt; &gt;<br/>&gt; &gt; 95% of Programmers consider 95% of the code they did not write, in the<br/>&gt; &gt; bottom<br/>&gt; &gt; 5%.<br/>&gt; &gt;<br/>&gt; &gt; Please reply to list if it&#39;s a mailing list post - http://shlom.in/reply .<br/>&gt; &gt;<br/>&gt; &gt; --<br/>&gt; &gt; To unsubscribe, e-mail: beginners-unsubscribe@perl.org<br/>&gt; &gt; For additional commands, e-mail: beginners-help@perl.org<br/>&gt; &gt; http://learn.perl.org/<br/>&gt; &gt;<br/>&gt; &gt;<br/>&gt; &gt;<br/><br/><br/><br/>-- <br/>-----------------------------------------------------------------<br/>Shlomi Fish http://www.shlomifish.org/<br/>Interview with Ben Collins-Sussman - http://shlom.in/sussman<br/><br/>Where they have burned books, they will end in burning human beings.<br/> &mdash; http://en.wikiquote.org/wiki/Heinrich_Heine<br/><br/>Please reply to list if it&#39;s a mailing list post - http://shlom.in/reply .<br/> http://www.nntp.perl.org/group/perl.beginners/2013/05/msg122866.html Tue, 14 May 2013 13:27:46 +0000 Re: what's the problem with a system call by xiaolan Thanks all the answers.<br/>Shlomi long time no see :)<br/><br/>Have another question that, what&#39;s the difference between the system call<br/>child process and the native forked child process?<br/>Does the child process of system call have the problems of receiving<br/>signals from the parent?<br/><br/><br/><br/><br/>On Tue, May 14, 2013 at 5:16 PM, Shlomi Fish &lt;shlomif@shlomifish.org&gt; wrote:<br/><br/>&gt; Hi Brian,<br/>&gt;<br/>&gt; thanks for replying well to xiaolan&rsquo;s question.<br/>&gt;<br/>&gt; Regards,<br/>&gt;<br/>&gt; Shlomi Fish<br/>&gt;<br/>&gt; --<br/>&gt; -----------------------------------------------------------------<br/>&gt; Shlomi Fish http://www.shlomifish.org/<br/>&gt; My Public Domain Photos - http://www.flickr.com/photos/shlomif/<br/>&gt;<br/>&gt; 95% of Programmers consider 95% of the code they did not write, in the<br/>&gt; bottom<br/>&gt; 5%.<br/>&gt;<br/>&gt; Please reply to list if it&#39;s a mailing list post - http://shlom.in/reply .<br/>&gt;<br/>&gt; --<br/>&gt; To unsubscribe, e-mail: beginners-unsubscribe@perl.org<br/>&gt; For additional commands, e-mail: beginners-help@perl.org<br/>&gt; http://learn.perl.org/<br/>&gt;<br/>&gt;<br/>&gt;<br/><br/> http://www.nntp.perl.org/group/perl.beginners/2013/05/msg122865.html Tue, 14 May 2013 10:52:03 +0000 Re: what's the problem with a system call by Shlomi Fish Hi Brian,<br/><br/>thanks for replying well to xiaolan&rsquo;s question.<br/><br/>Regards,<br/><br/> Shlomi Fish<br/><br/>-- <br/>-----------------------------------------------------------------<br/>Shlomi Fish http://www.shlomifish.org/<br/>My Public Domain Photos - http://www.flickr.com/photos/shlomif/<br/><br/>95% of Programmers consider 95% of the code they did not write, in the bottom<br/>5%.<br/><br/>Please reply to list if it&#39;s a mailing list post - http://shlom.in/reply .<br/> http://www.nntp.perl.org/group/perl.beginners/2013/05/msg122864.html Tue, 14 May 2013 09:16:49 +0000 Re: what's the problem with a system call by Brian Fraser On Tue, May 14, 2013 at 12:35 AM, xiaolan &lt;practicalperl@gmail.com&gt; wrote:<br/><br/>&gt; Hello,<br/>&gt;<br/>&gt; what&#39;s the disadvantage when calling a system command from Perl?<br/>&gt; i.e, system call to &quot;rsync&quot; rather than using the File::Rsync module.<br/>&gt; is it hard to control the signals between the caller process and the<br/>&gt; called system command?<br/>&gt;<br/><br/>The only real disadvantage is portability, perhaps speed (e.g. PerlIO::gzip<br/>is faster than calling gzip itself, and if you&#39;re shelling out multiple<br/>times, it&#39;ll generally be slower than simply using a module).<br/>Additionally, if you&#39;re passing user-provided arguments to the outside<br/>command and aren&#39;t doing things &quot;properly&quot;, that is, you aren&#39;t using<br/>IPC::Cmd, IPC::Run, or multi-arg open, you have a potential security hole<br/>in your program.<br/><br/>But if what you&#39;re doing doesn&#39;t gain any advantages from increased<br/>portability or security, there&#39;s nothing wrong with calling a system<br/>command.<br/><br/> http://www.nntp.perl.org/group/perl.beginners/2013/05/msg122863.html Tue, 14 May 2013 07:00:10 +0000 Re: what's the problem with a system call by Luca Ferrari On Tue, May 14, 2013 at 5:35 AM, xiaolan &lt;practicalperl@gmail.com&gt; wrote:<br/>&gt; Hello,<br/>&gt;<br/>&gt; what&#39;s the disadvantage when calling a system command from Perl?<br/>&gt; i.e, system call to &quot;rsync&quot; rather than using the File::Rsync module.<br/>&gt; is it hard to control the signals between the caller process and the called<br/>&gt; system command?<br/><br/><br/>Well, usually using a module you have access to several things in a<br/>Perl way, like for instance to the arguments to pass to the command as<br/>an hash or an array. instead of a string. Moreover, the perl module<br/>could have some workarounds to provide you better portability.<br/><br/>Luca<br/> http://www.nntp.perl.org/group/perl.beginners/2013/05/msg122862.html Tue, 14 May 2013 06:15:17 +0000 what's the problem with a system call by xiaolan Hello,<br/><br/>what&#39;s the disadvantage when calling a system command from Perl?<br/>i.e, system call to &quot;rsync&quot; rather than using the File::Rsync module.<br/>is it hard to control the signals between the caller process and the called<br/>system command?<br/><br/>Thanks.<br/><br/> http://www.nntp.perl.org/group/perl.beginners/2013/05/msg122861.html Tue, 14 May 2013 03:35:57 +0000 Re: script dies when Net::DNS resolve fails by Dr.Ruud On 13/05/2013 18:08, David Precious wrote:<br/><br/>&gt; The usual way to catch exceptions is with an eval block or Try::Tiny<br/>&gt; etc.<br/>&gt;<br/>&gt; Basic example:<br/>&gt;<br/>&gt; my $source_address = eval { $res-&gt;query(....); };<br/>&gt;<br/>&gt; if ($@) {<br/>&gt; # an error occurred - $@ will contain the message<br/>&gt; # do something appropriate here<br/>&gt; }<br/><br/>Testing $@ is basically always wrong, because it is a global variable <br/>that can have changed value.<br/><br/>A rewrite:<br/><br/> my $source_address;<br/> eval {<br/> $source_address = $res-&gt;query(....);<br/> 1; # success<br/> }<br/> or do {<br/> my $eval_error = $@ || &#39;Zombie Error&#39;;<br/> ...;<br/> };<br/><br/>-- <br/>Ruud<br/><br/> http://www.nntp.perl.org/group/perl.beginners/2013/05/msg122860.html Mon, 13 May 2013 19:02:32 +0000