perl.beginners http://www.nntp.perl.org/group/perl.beginners/ ... Copyright 1998-2014 perl.org Sat, 25 Oct 2014 19:54:46 +0000 ask@perl.org RE: masks earlier declaration in same scope by Boylan, Ross Thanks for your tips; they led to some experiments and gradual understanding of references. I&#39;m still puzzled by the error messages.<br/><br/>BACKGROUND<br/>Substantively, I am trying to modify Debian&#39;s adduser code so that it pays attention to a template of values from a previous system, to preserve the name -&gt; [gu]id mapping as well as group membership. Line 272 checks if such a template is present; 274 checks that the template is consistent with the current system values and populates %template with the desired values; 275 merges the group information from the template into the present system if that hasn&#39;t already been done.<br/><br/>%template is a hash with various tables in it. $template{uname} is a reference to another hash that has user names as keys and a reference to an array of values from the passwd file as values.<br/><br/>I am having trouble keeping the various levels of indirection straight.<br/><br/>EXPERIMENTS<br/>Here&#39;s a simpler example (excerpts) that fails, with a final version that works:<br/>--------------------------------------------------<br/>use warnings;<br/>use strict;<br/><br/>my %passwd;<br/><br/>open PASSWD, &quot;/mnt/lenny/etc/passwd&quot;;<br/>while (&lt;PASSWD&gt;) {<br/> my @line = split /:/;<br/> $passwd{$line[0]} = \@line;<br/> }<br/>close(PASSWD);<br/><br/>my %template;<br/>$template{uname} = \%passwd;<br/><br/>## below, the statement is followed by its output when run<br/><br/>print &#39;$template{uname}{ross} =&#39; , $template{uname}{ross}, &quot;\n&quot;;<br/>#$template{uname}{ross} =ARRAY(0x20f41d8)<br/># I&#39;m still surprised this worked. Somehow we&#39;ve gone 2 levels down with one $.<br/><br/>print &#39;${$template{uname}}{ross} =&#39; , ${$template{uname}}{ross}, &quot;\n&quot;;<br/>#${$template{uname}}{ross} =ARRAY(0x20f41d8)<br/># and thought this syntax was necessary<br/><br/>print &#39;$${$template{uname}}{ross} =&#39; , $${$template{uname}}{ross}, &quot;\n&quot;; <br/>#Not a SCALAR reference at testuser line 51.<br/> <br/>print &#39;@${$template{uname}}{ross} =&#39; , @${$template{uname}}{ross}, &quot;\n&quot;; <br/>#Not a SCALAR reference at testuser line 53. <br/># My thinking here is that <br/>print &#39;@$${$template{uname}}{ross} =&#39; , @$${$template{uname}}{ross}, &quot;\n&quot;;<br/>#Not a SCALAR reference at testuser line 55. <br/><br/>print &#39;@${${$template{uname}}{ross}} =&#39; , @${${$template{uname}}{ross}}, &quot;\n&quot;;<br/>#Not a SCALAR reference at testuser line 55. <br/> <br/>print ${$template{uname}{ross}}, &quot;\n&quot;; <br/># Not a SCALAR reference at testuser line 59. <br/><br/>print @{$template{uname}{ross}}, &quot;\n&quot;;<br/>#rossx10001000Ross Boylan,,,/home/ross/bin/bash <br/>-------------------------------------------------------------------------<br/><br/>SOLUTION (?)<br/>After studying perlreftut, I think my basic confusion was that I thought an additional level of $ was necessary.<br/>For example, my logic was that if ${$template{uname}}{ross} was a reference to an array then $${$template{uname}}{ross} was the array itself. When that didn&#39;t work I tried adding an @ in front.<br/><br/>So I&#39;ll fix my syntax problems, but I&#39;m still puzzled why the error messages aren&#39;t more helpful<br/><br/><br/>MORE BACKGROUND AND A QUESTION<br/>$new_name is the name of the new user that was requested when adduser was invoked.<br/>280 attempts to retrieve the array of information associated with the user in the template.<br/>So $template{uname} gets the reference to a hash. $($template{uname}) is the 2nd level hash itself [wrong],<br/>and $$($template{uname}){$new_name} the reference to the array for $new_name [not quite].<br/>This interpretation makes my original code, assigning to $old, seem more reasonable, since the result is a reference to an array, not an array. As noted in my original message, that version didn&#39;t work either.<br/><br/>If 280 alone generates a syntax error, why wasn&#39;t one reported for 280 by perl -c?<br/><br/>%template{uname} may not exist, and if it does it may not have entry for $new_name. 284 was relying on failure being null and failing tests, specifically at 280.<br/><br/>I tried<br/> if (my @old = @$($template{uname}){$new_name}) {<br/>but it the same error at 283 as the first error (the version with scope, not statement).<br/>The if test at 284 checks if the user has specified an option giving the new uid and, if so, whether it is consistent with the template value. <br/><br/>Finally,<br/>&gt; Did you really intend to declare and populate an array and throw in a conditional all in a one-liner?<br/>Yes.<br/><br/>&gt; Do you know for instance that my @foo = $some_scalar is the equivalent of <br/>&gt; just saying: my @foo = ($some_scalar)<br/>I didn&#39;t, though I have been wondering if &quot;return (0);&quot; is the same as &quot;return 0;&quot;. I guessing that to return a list with 0 in one would need return((0)). Is that riight? Or does it just depend on the context to which the value is returned? How does perl know whether (0) = a scalar expression with parentheses for precedence grouping (vacuously in this case); or a single element list; or, if a function precedes it, () indicating function arguments?<br/><br/>Ross<br/><br/>P.S. Sorry, my mail client basically forces top-posting.<br/>________________________________________<br/>From: Charles DeRykus [derykus@gmail.com]<br/>Sent: Monday, October 13, 2014 11:08 AM<br/>To: Boylan, Ross<br/>Subject: Re: masks earlier declaration in same scope<br/><br/>On Mon, Oct 13, 2014 at 1:04 AM, Boylan, Ross &lt;Ross.Boylan@ucsf.edu&gt; wrote:<br/>&gt; perl -c adduser gives its first error as<br/>&gt; &quot;my&quot; variable $new_uid masks earlier declaration in same scope at adduser line 283.<br/>&gt; First, it doesn&#39;t seem to me I&#39;m declaring the variable at all at 283. I suppose it could be an implicit declaration if there wasn&#39;t a previous declaration, but there is at 103.<br/>&gt; Second, I don&#39;t see any earlier declarations in any scope except the outer one.<br/>&gt; Third, the variiable was declared, with &quot;our $new_uid;&quot; much earlier in the file.<br/>&gt;<br/>&gt; Could anyone explain to me what&#39;s going on? A couple other questions appear after the code.<br/>&gt; 32 use warnings;<br/>&gt; 33 use strict;<br/>&gt; 34 use Debian::AdduserCommon;<br/>&gt; 35 use Getopt::Long;<br/>&gt; 36 use File::Spec::Functions;<br/>&gt; 37 use File::Touch;<br/>&gt; ...<br/>&gt; 103 our $new_uid = undef;<br/>&gt; ....<br/>&gt; 160 # Parse options, sanity checks<br/>&gt; 161 unless ( GetOptions (&quot;quiet|q&quot; =&gt; sub { $verbose = 0 },<br/>&gt; ...<br/>&gt; 173 &quot;uid=i&quot; =&gt; \$new_uid, # still in arguments to GetOptions<br/>&gt; Lines 103 and 173 are the only places $new_uid occurs in the text before line 283.<br/>&gt;<br/>&gt; 272 if ($use_template = &amp;use_template) {<br/>&gt; 273 # we are using templates<br/>&gt; 274 if (check_template( $conf_dir, \%template)) {<br/>&gt; 275 merge_template( \%template, \%system)<br/>&gt; 276 }<br/>&gt; 277 # rewrite request as needed<br/>&gt; 278 if defined($new_name) {<br/>&gt; 279 # trying to create a new user<br/>&gt; 280 if (my @old = $$($template{uname}){$new_name}) {<br/>&gt; 281 # requested user is in the template<br/>&gt; 282 my $olduid = $$old[2];<br/>&gt; **283 dief( gtx(&quot;Specified UID %d for %s does not match template UID of %d.\n&quot;), $new_uid,<br/>&gt; 284 $new_name, $olduid) if defined($new_uid) &amp;&amp; $new_uid != $olduid;<br/>&gt; 285 $new_uid = $olduid;<br/>&gt; 286 my $oldgid = $$old[3];<br/>&gt;<br/>&gt; Bonus question #1: Where does the relevant scope start? I think it&#39;s 280, but if none of the if&#39;s create scopes it could be the start of the file.<br/>&gt;<br/>&gt; Bonus question #2: If I change 280 to to &quot;if (my $old = ....&quot; I get the error<br/>&gt; &quot;my&quot; variable $old masks earlier declaration in same statement at adduser line 282.<br/>&gt; Why? I mean, there&#39;s only declaration in the statement, and it seems to be on the first line even if the &quot;statement&quot; is everything up to the end of the if .. else .. block.<br/>&gt;<br/>&gt; The archives indicate that syntax errors sometimes produce seemingly unrelated &quot;masks earlier declaration&quot; errors, but even if this is a syntax error (it seems more like a semantic problem to me) the error seems odd.<br/><br/><br/>LIne 280 alone will generate a syntax error:<br/><br/>$ perl -we &#39;if (my @old = $$($template{uname}){$new_name}) {}&#39;<br/> syntax error at -e line 1, near &quot;$$(&quot;<br/><br/><br/>Perhaps you meant somethng like:<br/><br/> if (my @old = ( ${$template{uname}{$new_name}} ) ) { .... }<br/><br/><br/>But that&#39;s really bizarre too. Did you really intend to declare and<br/>populate an array and throw in a conditional all in a one-liner?<br/><br/>Do you know for instance that my @foo = $some_scalar is the equivalent<br/>of just saying: my @foo = ($some_scalar); The latter is the usual idiom<br/>and is clearer too.<br/><br/>So, just a few thoughts... some more explanation of what that code is<br/>intended to do would help.<br/><br/>--<br/>Charles DeRykus<br/> http://www.nntp.perl.org/group/perl.beginners/2014/10/msg124864.html Tue, 14 Oct 2014 05:07:39 +0000 RE: masks earlier declaration in same scope by Boylan, Ross I think I figured out one thing from my earlier message:<br/>----------------------------<br/>print &#39;$template{uname}{ross} =&#39; , $template{uname}{ross}, &quot;\n&quot;;<br/>#$template{uname}{ross} =ARRAY(0x20f41d8)<br/># I&#39;m still surprised this worked. Somehow we&#39;ve gone 2 levels down with one $.<br/><br/>print &#39;${$template{uname}}{ross} =&#39; , ${$template{uname}}{ross}, &quot;\n&quot;;<br/>#${$template{uname}}{ross} =ARRAY(0x20f41d8)<br/># and thought this syntax was necessary<br/>-----------------------------------------------<br/><br/>I think the first one works because it is implicitly converted to<br/>$template{uname}-&gt;{ross}<br/>which is equivalent to the second version. The reference tutorial doesn&#39;t mention that this trick works with hashes that I could see.<br/><br/>Ross http://www.nntp.perl.org/group/perl.beginners/2014/10/msg124863.html Tue, 14 Oct 2014 05:07:38 +0000 Re: masks earlier declaration in same scope by Charles DeRykus On Mon, Oct 13, 2014 at 1:04 AM, Boylan, Ross &lt;Ross.Boylan@ucsf.edu&gt; wrote:<br/>&gt; perl -c adduser gives its first error as<br/>&gt; &quot;my&quot; variable $new_uid masks earlier declaration in same scope at adduser line 283.<br/>&gt; First, it doesn&#39;t seem to me I&#39;m declaring the variable at all at 283. I suppose it could be an implicit declaration if there wasn&#39;t a previous declaration, but there is at 103.<br/>&gt; Second, I don&#39;t see any earlier declarations in any scope except the outer one.<br/>&gt; Third, the variiable was declared, with &quot;our $new_uid;&quot; much earlier in the file.<br/>&gt;<br/>&gt; Could anyone explain to me what&#39;s going on? A couple other questions appear after the code.<br/>&gt; 32 use warnings;<br/>&gt; 33 use strict;<br/>&gt; 34 use Debian::AdduserCommon;<br/>&gt; 35 use Getopt::Long;<br/>&gt; 36 use File::Spec::Functions;<br/>&gt; 37 use File::Touch;<br/>&gt; ...<br/>&gt; 103 our $new_uid = undef;<br/>&gt; ....<br/>&gt; 160 # Parse options, sanity checks<br/>&gt; 161 unless ( GetOptions (&quot;quiet|q&quot; =&gt; sub { $verbose = 0 },<br/>&gt; ...<br/>&gt; 173 &quot;uid=i&quot; =&gt; \$new_uid, # still in arguments to GetOptions<br/>&gt; Lines 103 and 173 are the only places $new_uid occurs in the text before line 283.<br/>&gt;<br/>&gt; 272 if ($use_template = &amp;use_template) {<br/>&gt; 273 # we are using templates<br/>&gt; 274 if (check_template( $conf_dir, \%template)) {<br/>&gt; 275 merge_template( \%template, \%system)<br/>&gt; 276 }<br/>&gt; 277 # rewrite request as needed<br/>&gt; 278 if defined($new_name) {<br/>&gt; 279 # trying to create a new user<br/>&gt; 280 if (my @old = $$($template{uname}){$new_name}) {<br/>&gt; 281 # requested user is in the template<br/>&gt; 282 my $olduid = $$old[2];<br/>&gt; **283 dief( gtx(&quot;Specified UID %d for %s does not match template UID of %d.\n&quot;), $new_uid,<br/>&gt; 284 $new_name, $olduid) if defined($new_uid) &amp;&amp; $new_uid != $olduid;<br/>&gt; 285 $new_uid = $olduid;<br/>&gt; 286 my $oldgid = $$old[3];<br/>&gt;<br/>&gt; Bonus question #1: Where does the relevant scope start? I think it&#39;s 280, but if none of the if&#39;s create scopes it could be the start of the file.<br/>&gt;<br/>&gt; Bonus question #2: If I change 280 to to &quot;if (my $old = ....&quot; I get the error<br/>&gt; &quot;my&quot; variable $old masks earlier declaration in same statement at adduser line 282.<br/>&gt; Why? I mean, there&#39;s only declaration in the statement, and it seems to be on the first line even if the &quot;statement&quot; is everything up to the end of the if .. else .. block.<br/>&gt;<br/>&gt; The archives indicate that syntax errors sometimes produce seemingly unrelated &quot;masks earlier declaration&quot; errors, but even if this is a syntax error (it seems more like a semantic problem to me) the error seems odd.<br/><br/><br/>LIne 280 alone will generate a syntax error:<br/><br/>$ perl -we &#39;if (my @old = $$($template{uname}){$new_<br/>name}) {}&#39;<br/> syntax error at -e line 1, near &quot;$$(&quot;<br/><br/><br/>Perhaps you meant somethng like:<br/><br/> if (my @old = ( ${$template{uname}{$new_name}} ) ) { .... }<br/><br/><br/>But that&#39;s really bizarre too. Did you really intend to declare and<br/>populate an array and throw in a conditional all in a one-liner?<br/><br/>Do you know for instance that my @foo = $some_scalar is the equivalent<br/>of just saying: my @foo = ($some_scalar).<br/><br/>So, just a few thoughts... some more explanation of what that code is<br/>intended to do would help.<br/><br/>-- <br/>Charles DeRykus<br/> http://www.nntp.perl.org/group/perl.beginners/2014/10/msg124862.html Mon, 13 Oct 2014 18:43:10 +0000 masks earlier declaration in same scope by Boylan, Ross perl -c adduser gives its first error as<br/>&quot;my&quot; variable $new_uid masks earlier declaration in same scope at adduser line 283.<br/>First, it doesn&#39;t seem to me I&#39;m declaring the variable at all at 283. I suppose it could be an implicit declaration if there wasn&#39;t a previous declaration, but there is at 103.<br/>Second, I don&#39;t see any earlier declarations in any scope except the outer one.<br/>Third, the variiable was declared, with &quot;our $new_uid;&quot; much earlier in the file.<br/><br/>Could anyone explain to me what&#39;s going on? A couple other questions appear after the code.<br/> 32 use warnings;<br/> 33 use strict;<br/> 34 use Debian::AdduserCommon;<br/> 35 use Getopt::Long;<br/> 36 use File::Spec::Functions;<br/> 37 use File::Touch;<br/>...<br/> 103 our $new_uid = undef;<br/>....<br/> 160 # Parse options, sanity checks<br/> 161 unless ( GetOptions (&quot;quiet|q&quot; =&gt; sub { $verbose = 0 },<br/>...<br/> 173 &quot;uid=i&quot; =&gt; \$new_uid, # still in arguments to GetOptions<br/>Lines 103 and 173 are the only places $new_uid occurs in the text before line 283.<br/> <br/> 272 if ($use_template = &amp;use_template) {<br/> 273 # we are using templates<br/> 274 if (check_template( $conf_dir, \%template)) {<br/> 275 merge_template( \%template, \%system)<br/> 276 }<br/> 277 # rewrite request as needed<br/> 278 if defined($new_name) {<br/> 279 # trying to create a new user<br/> 280 if (my @old = $$($template{uname}){$new_name}) {<br/> 281 # requested user is in the template<br/> 282 my $olduid = $$old[2];<br/>**283 dief( gtx(&quot;Specified UID %d for %s does not match template UID of %d.\n&quot;), $new_uid,<br/> 284 $new_name, $olduid) if defined($new_uid) &amp;&amp; $new_uid != $olduid;<br/> 285 $new_uid = $olduid;<br/> 286 my $oldgid = $$old[3];<br/><br/>Bonus question #1: Where does the relevant scope start? I think it&#39;s 280, but if none of the if&#39;s create scopes it could be the start of the file.<br/><br/>Bonus question #2: If I change 280 to to &quot;if (my $old = ....&quot; I get the error<br/>&quot;my&quot; variable $old masks earlier declaration in same statement at adduser line 282.<br/>Why? I mean, there&#39;s only declaration in the statement, and it seems to be on the first line even if the &quot;statement&quot; is everything up to the end of the if .. else .. block.<br/><br/>The archives indicate that syntax errors sometimes produce seemingly unrelated &quot;masks earlier declaration&quot; errors, but even if this is a syntax error (it seems more like a semantic problem to me) the error seems odd.<br/><br/>Thanks.<br/>Ross Boylan<br/><br/>P.S. This is perl 5, version 14, subversion 2 (v5.14.2) built for x86_64-linux-gnu-thread-multi<br/>(with 88 registered patches, see perl -V for more detail)<br/> http://www.nntp.perl.org/group/perl.beginners/2014/10/msg124861.html Mon, 13 Oct 2014 12:59:28 +0000 Re: Where to put example script of my CPAN distribution by Shlomi Fish Hi Sebastien!<br/><br/>On Thu, 9 Oct 2014 23:16:51 +0200<br/>Sebastien Feugere &lt;seb.feugere@gmail.com&gt; wrote:<br/><br/>&gt; You can put a simple example in the POD&#39;s &quot;SYNOPSYS&quot; section of your module<br/>&gt; as you can find on most of Perl modules (check a random CPAN module to see).<br/>&gt; <br/>&gt; See :<br/>&gt; * http://juerd.nl/site.plp/perlpodtut<br/>&gt; * http://perldoc.perl.org/perlpodstyle.html<br/>&gt; <br/>&gt; <br/><br/>As desirable this is (and it is very desirable) - this is not a substitute for<br/>an &quot;examples/&quot; or a &quot;eg/&quot; directory.<br/><br/>Regards,<br/><br/> Shlomi Fish<br/><br/>-- <br/>-----------------------------------------------------------------<br/>Shlomi Fish http://www.shlomifish.org/<br/>Rethinking CPAN - http://shlom.in/rethinking-cpan<br/><br/>E&#x2010;mail, web feeds, and doing something productive &mdash; choose two.<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/2014/10/msg124860.html Fri, 10 Oct 2014 06:34:50 +0000 Re: Where to put example script of my CPAN distribution by Shlomi Fish Hi Alex,<br/><br/>On Thu, 9 Oct 2014 22:52:19 +0200<br/>Alex Becker &lt;asb.cpan@gmail.com&gt; wrote:<br/><br/>&gt; Hi all!<br/>&gt; <br/>&gt; Similar to my question about the lib folder of a Perl module, I would like<br/>&gt; to knoe where one should put example scripts in a CPAN distribution.<br/>&gt; <br/>&gt; I&#39;ve seen modules using an eg folder and I&#39;m always tempted to use a more<br/>&gt; mnemonic version: examples.<br/>&gt; <br/><br/>I think both &quot;eg/&quot; and &quot;examples/&quot; are fine:<br/><br/>http://www.nntp.perl.org/group/perl.qa/2006/03/msg5581.html<br/><br/>Seems like this Kwalitee measurement was removed from some reason.<br/><br/>Regards,<br/><br/> Shlomi Fish<br/><br/>&gt; Is there a best practice? I know of TIMTOWTDI but I don&#39;t care, I just want<br/>&gt; to deliver something that people can easily use.<br/>&gt; <br/>&gt; Thanks in advance &amp; kind regards,<br/>&gt; Alex<br/><br/><br/><br/>-- <br/>-----------------------------------------------------------------<br/>Shlomi Fish http://www.shlomifish.org/<br/>Why I Love Perl - http://shlom.in/joy-of-perl<br/><br/>SGLau: By the way, herr Frog: it is not that hard to be green.<br/> &mdash; http://is.gd/htmOCv<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/2014/10/msg124859.html Fri, 10 Oct 2014 06:29:32 +0000 Re: Where to put example script of my CPAN distribution by Alex Hm, I was thinking about more sophisticated examples, showing distinct, common use cases. That is, for example, code which is too lengthy to be included in the POD. Maybe something that will run out of the box.<br/>I&#39;m looking for a place for code that I consider disturbing when included in the modules documentation. <br/>Imagine an API with some common use cases. Present them as a fully working script allows a programmer to get started easily.<br/><br/>Of course, always in addition to a good synopsis :)<br/><br/>&gt; Am 09.10.2014 um 23:16 schrieb Sebastien Feugere &lt;seb.feugere@gmail.com&gt;:<br/>&gt; <br/>&gt; You can put a simple example in the POD&#39;s &quot;SYNOPSYS&quot; section of your module as you can find on most of Perl modules (check a random CPAN module to see).<br/>&gt; <br/>&gt; See :<br/>&gt; * http://juerd.nl/site.plp/perlpodtut<br/>&gt; * http://perldoc.perl.org/perlpodstyle.html<br/>&gt; <br/>&gt; <br/>&gt; ~$&amp;bast1<br/>&gt; <br/>&gt;&gt; On Thu, Oct 9, 2014 at 10:52 PM, Alex Becker &lt;asb.cpan@gmail.com&gt; wrote:<br/>&gt;&gt; Hi all!<br/>&gt;&gt; <br/>&gt;&gt; Similar to my question about the lib folder of a Perl module, I would like to knoe where one should put example scripts in a CPAN distribution.<br/>&gt;&gt; <br/>&gt;&gt; I&#39;ve seen modules using an eg folder and I&#39;m always tempted to use a more mnemonic version: examples. <br/>&gt;&gt; <br/>&gt;&gt; Is there a best practice? I know of TIMTOWTDI but I don&#39;t care, I just want to deliver something that people can easily use.<br/>&gt;&gt; <br/>&gt;&gt; Thanks in advance &amp; kind regards,<br/>&gt;&gt; Alex<br/>&gt; <br/><br/> http://www.nntp.perl.org/group/perl.beginners/2014/10/msg124858.html Thu, 09 Oct 2014 22:08:03 +0000 Re: Interactive perl based application who works as per schedule by Benjamin Fernandis Thanks,<br/><br/>I will follow those.<br/><br/>Regards<br/><br/>On Fri, Oct 10, 2014 at 3:26 AM, Christopher Brenk &lt;<br/>christopherbrenk@googlemail.com&gt; wrote:<br/><br/>&gt; Hi!<br/>&gt;<br/>&gt; I just read a article on perltricks.com about every. It&#39;s an application<br/>&gt; written in Perl,which provides a interface to cron.<br/>&gt;<br/>&gt;<br/>&gt; http://perltricks.com/article/55/2013/12/22/Schedule-jobs-like-a-boss-with-every<br/>&gt;<br/>&gt; Maybe you want to use it in your (web-)application.<br/>&gt;<br/>&gt; Mit freundlichen Gr&uuml;&szlig;en,<br/>&gt; Christopher Brenk.<br/>&gt; Am 09.10.2014 15:55 schrieb &quot;John SJ Anderson&quot; &lt;genehack@genehack.org&gt;:<br/>&gt;<br/>&gt; On Thu, Oct 9, 2014 at 2:19 AM, Benjamin Fernandis &lt;benjo11111@gmail.com&gt;<br/>&gt;&gt; wrote:<br/>&gt;&gt; &gt; Hi,<br/>&gt;&gt;<br/>&gt;&gt; Hi!<br/>&gt;&gt;<br/>&gt;&gt; [ snip ]<br/>&gt;&gt;<br/>&gt;&gt; &gt; Please suggest me for this.<br/>&gt;&gt;<br/>&gt;&gt; I suggest you don&#39;t try to re-invent cron. Cron works. Cron is a known<br/>&gt;&gt; quantity. You don&#39;t need to re-invent cron.<br/>&gt;&gt;<br/>&gt;&gt; What you need is a way to let other people edit crontab files, with a<br/>&gt;&gt; better UI. So make a Perl web application. Require authentication --<br/>&gt;&gt; tie it into your AD or LDAP or whatever -- and provide a UI that<br/>&gt;&gt; writes out a crontab file based on the users input.<br/>&gt;&gt;<br/>&gt;&gt; Then have a cronjob that runs every minute that looks at those crontab<br/>&gt;&gt; files, detects when one has been changed, and reloads it.<br/>&gt;&gt;<br/>&gt;&gt; chrs,<br/>&gt;&gt; john.<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/> http://www.nntp.perl.org/group/perl.beginners/2014/10/msg124857.html Thu, 09 Oct 2014 21:46:32 +0000 Re: Where to put example script of my CPAN distribution by Sebastien Feugere You can put a simple example in the POD&#39;s &quot;SYNOPSYS&quot; section of your module<br/>as you can find on most of Perl modules (check a random CPAN module to see).<br/><br/>See :<br/> * http://juerd.nl/site.plp/perlpodtut<br/> * http://perldoc.perl.org/perlpodstyle.html<br/><br/><br/>~$&amp;bast1<br/><br/>On Thu, Oct 9, 2014 at 10:52 PM, Alex Becker &lt;asb.cpan@gmail.com&gt; wrote:<br/><br/>&gt; Hi all!<br/>&gt;<br/>&gt; Similar to my question about the lib folder of a Perl module, I would like<br/>&gt; to knoe where one should put example scripts in a CPAN distribution.<br/>&gt;<br/>&gt; I&#39;ve seen modules using an eg folder and I&#39;m always tempted to use a more<br/>&gt; mnemonic version: examples.<br/>&gt;<br/>&gt; Is there a best practice? I know of TIMTOWTDI but I don&#39;t care, I just<br/>&gt; want to deliver something that people can easily use.<br/>&gt;<br/>&gt; Thanks in advance &amp; kind regards,<br/>&gt; Alex<br/>&gt;<br/><br/> http://www.nntp.perl.org/group/perl.beginners/2014/10/msg124856.html Thu, 09 Oct 2014 21:17:38 +0000 Where to put example script of my CPAN distribution by Alex Becker Hi all!<br/><br/>Similar to my question about the lib folder of a Perl module, I would like<br/>to knoe where one should put example scripts in a CPAN distribution.<br/><br/>I&#39;ve seen modules using an eg folder and I&#39;m always tempted to use a more<br/>mnemonic version: examples.<br/><br/>Is there a best practice? I know of TIMTOWTDI but I don&#39;t care, I just want<br/>to deliver something that people can easily use.<br/><br/>Thanks in advance &amp; kind regards,<br/>Alex<br/><br/> http://www.nntp.perl.org/group/perl.beginners/2014/10/msg124855.html Thu, 09 Oct 2014 20:52:26 +0000 Re: share a variable between files by Shawn H Corey On Wed, 8 Oct 2014 21:36:06 +0200<br/>Hans Ginzel &lt;hans@matfyz.cz&gt; wrote:<br/><br/>&gt; I want to use one global hash variable for options or configuration<br/>&gt; variables like verbose, debug. I don&#39;t want to pass them to each<br/>&gt; function or to almost each object.<br/><br/>package main;<br/>our %Opts = (<br/> verbose =&gt; 0,<br/> debug =&gt; 0.<br/>);<br/><br/># you can use %::Opts anywhere.<br/># See `perldoc -f our`<br/><br/><br/>-- <br/>Don&#39;t stop where the ink does.<br/> Shawn<br/> http://www.nntp.perl.org/group/perl.beginners/2014/10/msg124854.html Thu, 09 Oct 2014 14:46:04 +0000 Re: Interactive perl based application who works as per schedule by Christopher Brenk Hi!<br/><br/>I just read a article on perltricks.com about every. It&#39;s an application<br/>written in Perl,which provides a interface to cron.<br/><br/>http://perltricks.com/article/55/2013/12/22/Schedule-jobs-like-a-boss-with-every<br/><br/>Maybe you want to use it in your (web-)application.<br/><br/>Mit freundlichen Gr&uuml;&szlig;en,<br/>Christopher Brenk.<br/>Am 09.10.2014 15:55 schrieb &quot;John SJ Anderson&quot; &lt;genehack@genehack.org&gt;:<br/><br/>&gt; On Thu, Oct 9, 2014 at 2:19 AM, Benjamin Fernandis &lt;benjo11111@gmail.com&gt;<br/>&gt; wrote:<br/>&gt; &gt; Hi,<br/>&gt;<br/>&gt; Hi!<br/>&gt;<br/>&gt; [ snip ]<br/>&gt;<br/>&gt; &gt; Please suggest me for this.<br/>&gt;<br/>&gt; I suggest you don&#39;t try to re-invent cron. Cron works. Cron is a known<br/>&gt; quantity. You don&#39;t need to re-invent cron.<br/>&gt;<br/>&gt; What you need is a way to let other people edit crontab files, with a<br/>&gt; better UI. So make a Perl web application. Require authentication --<br/>&gt; tie it into your AD or LDAP or whatever -- and provide a UI that<br/>&gt; writes out a crontab file based on the users input.<br/>&gt;<br/>&gt; Then have a cronjob that runs every minute that looks at those crontab<br/>&gt; files, detects when one has been changed, and reloads it.<br/>&gt;<br/>&gt; chrs,<br/>&gt; john.<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/2014/10/msg124853.html Thu, 09 Oct 2014 14:26:56 +0000 Re: Interactive perl based application who works as per schedule by John SJ Anderson On Thu, Oct 9, 2014 at 2:19 AM, Benjamin Fernandis &lt;benjo11111@gmail.com&gt; wrote:<br/>&gt; Hi,<br/><br/>Hi!<br/><br/>[ snip ]<br/><br/>&gt; Please suggest me for this.<br/><br/>I suggest you don&#39;t try to re-invent cron. Cron works. Cron is a known<br/>quantity. You don&#39;t need to re-invent cron.<br/><br/>What you need is a way to let other people edit crontab files, with a<br/>better UI. So make a Perl web application. Require authentication --<br/>tie it into your AD or LDAP or whatever -- and provide a UI that<br/>writes out a crontab file based on the users input.<br/><br/>Then have a cronjob that runs every minute that looks at those crontab<br/>files, detects when one has been changed, and reloads it.<br/><br/>chrs,<br/>john.<br/> http://www.nntp.perl.org/group/perl.beginners/2014/10/msg124852.html Thu, 09 Oct 2014 13:55:37 +0000 Re: share a variable between files by Hans Ginzel On Thu, Oct 09, 2014 at 03:50:02AM +1300, Kent Fredric wrote:<br/>&gt; First, what are you trying to acheive.<br/>&gt; Global variables are rarely a good idea, as is sharing variables<br/>&gt; between files.<br/>&gt; So the question is, why are you trying to share a variable between<br/>&gt; files using globals?<br/>&gt; My suggestion is you should be using an exporter of some kind, or<br/>&gt; qualifying the variables by name at very least.<br/>&gt; Also, why are you *requiring* .pl files by string name? That is<br/>&gt; reasonably poor design and I would be interested in learning what<br/>&gt; educational material you are consuming that lead you to your current<br/>&gt; course of action so I can make a point of not recommending it =)<br/><br/>Thank you, Kent. I studied perldoc perl* pages years ago. Requiring I have made<br/>&quot;accidentally&quot; while stripping down the example. I wanted not to use &quot;use&quot;,<br/>to get rid of import.<br/><br/>I want to use one global hash variable for options or configuration variables<br/>like verbose, debug. I don&#39;t want to pass them to each function<br/>or to almost each object.<br/><br/>HG<br/> http://www.nntp.perl.org/group/perl.beginners/2014/10/msg124851.html Thu, 09 Oct 2014 13:21:05 +0000 Re: Best way to install perl modules by Shlomi Fish Hi Benjamin,<br/><br/>On Thu, 9 Oct 2014 22:11:41 +1300<br/>Benjamin Fernandis &lt;benjo11111@gmail.com&gt; wrote:<br/><br/>&gt; Hi Shlomi,<br/>&gt; <br/>&gt; Thanks. I also feel that centos/rhel perl seems brokern in terms of<br/>&gt; dependencies issues and some others.<br/><br/>You&#39;re welcome.<br/><br/>Regards,<br/><br/> Shlomi Fish<br/><br/>-- <br/>-----------------------------------------------------------------<br/>Shlomi Fish http://www.shlomifish.org/<br/>http://www.shlomifish.org/humour/bits/Google-Discontinues-Services/<br/><br/>&lt;Botje&gt; Khisanth =~ s/must sleep/must give Botje all my money/ .<br/> &mdash; Freenode&rsquo;s #perl<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/2014/10/msg124850.html Thu, 09 Oct 2014 13:12:54 +0000 Re: Best way to install perl modules by Sam Take note at least on rehl, you have to run &#39;yum install perl perl-core&#39; <br/>to get a full working perl (If I remember right).<br/><br/>--Sam<br/><br/>On 10/09/2014 04:11 AM, Benjamin Fernandis wrote:<br/>&gt; Hi Shlomi,<br/>&gt;<br/>&gt; Thanks. I also feel that centos/rhel perl seems brokern in terms of<br/>&gt; dependencies issues and some others.<br/>&gt;<br/>&gt; Regards<br/>&gt;<br/>&gt;<br/>&gt; On Thu, Oct 9, 2014 at 9:12 PM, Shlomi Fish &lt;shlomif@shlomifish.org<br/>&gt; &lt;mailto:shlomif@shlomifish.org&gt;&gt; wrote:<br/>&gt;<br/>&gt; Hi Benjamin,<br/>&gt;<br/>&gt; On Sun, 5 Oct 2014 17:39:46 +1300<br/>&gt; Benjamin Fernandis &lt;benjo11111@gmail.com<br/>&gt; &lt;mailto:benjo11111@gmail.com&gt;&gt; wrote:<br/>&gt;<br/>&gt; &gt; Hi Mike,<br/>&gt; &gt;<br/>&gt; &gt; Thanks for your kind response. I tried cpanm instead of cpan, but many<br/>&gt; &gt; times, it does not install require dependencies for module.<br/>&gt; &gt;<br/>&gt; &gt; For example, when i was trying to install<br/>&gt; &gt; cpanm XML::SAX -&gt; it failed and said no Fatal.pm module , then i manually<br/>&gt; &gt; first installed that module and then i tried to install XML::SAX and it<br/>&gt; &gt; works.<br/>&gt; &gt;<br/>&gt; &gt; It happens many times while installing different modules. I mean cpanm does<br/>&gt; &gt; not automatically fetch require dependencies for module. like yum in centos<br/>&gt; &gt; to install packages.<br/>&gt; &gt;<br/>&gt; &gt; Is there any tool or something like yum for perl module installations. Or<br/>&gt; &gt; Is there , I am missing anything ?<br/>&gt; &gt;<br/>&gt;<br/>&gt; The equivalents of yum in the Perl-world are cpan/CPAN.pm and<br/>&gt; cpanp/CPANPLUS.pm . Also see what I wrote about it here:<br/>&gt;<br/>&gt; * http://perl-begin.org/topics/cpan/<br/>&gt;<br/>&gt; * http://perl-begin.org/topics/cpan/wrappers-for-distributions/<br/>&gt;<br/>&gt; Note that the CentOS/RHEL/Fedora perl is suffering from several<br/>&gt; issues and the<br/>&gt; general wisdom is that you should install your own perl under a<br/>&gt; prefix using<br/>&gt; perlbrew - http://perlbrew.pl/ .<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; Apple Inc. is Evil - http://www.shlomifish.org/open-source/anti/apple/<br/>&gt;<br/>&gt; You can never truly appreciate The Gilmore Girls until you&rsquo;ve<br/>&gt; watched it in<br/>&gt; the original Klingon.<br/>&gt;<br/>&gt; Please reply to list if it&#39;s a mailing list post -<br/>&gt; http://shlom.in/reply .<br/>&gt;<br/>&gt;<br/><br/> http://www.nntp.perl.org/group/perl.beginners/2014/10/msg124849.html Thu, 09 Oct 2014 12:37:08 +0000 Interactive perl based application who works as per schedule by Benjamin Fernandis Hi,<br/><br/><br/>I develop some scripts which we use with OS crontab to schedule to run<br/>certain scripts. Scripts are for backup , VM on/off etc...<br/><br/>I want to integrate crontab function within perl script to do this.<br/><br/>Like a perl based daemon, which accepts date/time and action from users and<br/>run according to that.<br/><br/>currently i define in cronjob<br/><br/>example : 10 10 * * * /opt/scripts/stop_vm.pl &lt;VM_ID&gt;<br/><br/><br/>What is the better way to make it interactive with other team members , so<br/>they can add/modify/remove schedule jobs with scripts.<br/><br/>I am thinking to make it as web based and different scripts which we are<br/>currently using ( stop_vm.pl , start_vm.pl , backup.pl etc...), convert<br/>them into module and then use those modules from main script which acts as<br/>per schedule and complete certain task.<br/><br/>Please suggest me for this.<br/><br/>Regards<br/><br/> http://www.nntp.perl.org/group/perl.beginners/2014/10/msg124848.html Thu, 09 Oct 2014 09:19:41 +0000 Re: Best way to install perl modules by Benjamin Fernandis Hi Shlomi,<br/><br/>Thanks. I also feel that centos/rhel perl seems brokern in terms of<br/>dependencies issues and some others.<br/><br/>Regards<br/><br/><br/>On Thu, Oct 9, 2014 at 9:12 PM, Shlomi Fish &lt;shlomif@shlomifish.org&gt; wrote:<br/><br/>&gt; Hi Benjamin,<br/>&gt;<br/>&gt; On Sun, 5 Oct 2014 17:39:46 +1300<br/>&gt; Benjamin Fernandis &lt;benjo11111@gmail.com&gt; wrote:<br/>&gt;<br/>&gt; &gt; Hi Mike,<br/>&gt; &gt;<br/>&gt; &gt; Thanks for your kind response. I tried cpanm instead of cpan, but many<br/>&gt; &gt; times, it does not install require dependencies for module.<br/>&gt; &gt;<br/>&gt; &gt; For example, when i was trying to install<br/>&gt; &gt; cpanm XML::SAX -&gt; it failed and said no Fatal.pm module , then i<br/>&gt; manually<br/>&gt; &gt; first installed that module and then i tried to install XML::SAX and it<br/>&gt; &gt; works.<br/>&gt; &gt;<br/>&gt; &gt; It happens many times while installing different modules. I mean cpanm<br/>&gt; does<br/>&gt; &gt; not automatically fetch require dependencies for module. like yum in<br/>&gt; centos<br/>&gt; &gt; to install packages.<br/>&gt; &gt;<br/>&gt; &gt; Is there any tool or something like yum for perl module installations. Or<br/>&gt; &gt; Is there , I am missing anything ?<br/>&gt; &gt;<br/>&gt;<br/>&gt; The equivalents of yum in the Perl-world are cpan/CPAN.pm and<br/>&gt; cpanp/CPANPLUS.pm . Also see what I wrote about it here:<br/>&gt;<br/>&gt; * http://perl-begin.org/topics/cpan/<br/>&gt;<br/>&gt; * http://perl-begin.org/topics/cpan/wrappers-for-distributions/<br/>&gt;<br/>&gt; Note that the CentOS/RHEL/Fedora perl is suffering from several issues and<br/>&gt; the<br/>&gt; general wisdom is that you should install your own perl under a prefix<br/>&gt; using<br/>&gt; perlbrew - http://perlbrew.pl/ .<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; Apple Inc. is Evil - http://www.shlomifish.org/open-source/anti/apple/<br/>&gt;<br/>&gt; You can never truly appreciate The Gilmore Girls until you&rsquo;ve watched it in<br/>&gt; the original Klingon.<br/>&gt;<br/>&gt; Please reply to list if it&#39;s a mailing list post - http://shlom.in/reply .<br/>&gt;<br/><br/> http://www.nntp.perl.org/group/perl.beginners/2014/10/msg124847.html Thu, 09 Oct 2014 09:11:49 +0000 Re: Why to use a lib folder for a CPAN module by Ken Peng <br/><br/>Module-starter is cool. I always use that for my packages management.<br/><br/>&gt; First of all, you should not use h2xs, but rather Dist-Zilla or Module-Starter<br/>&gt; (https://metacpan.org/release/Module-Starter ).<br/> http://www.nntp.perl.org/group/perl.beginners/2014/10/msg124846.html Thu, 09 Oct 2014 08:25:15 +0000 Re: Why to use a lib folder for a CPAN module by Shlomi Fish Hi Alex,<br/><br/>On Wed, 8 Oct 2014 19:59:12 +0200<br/>Alex Becker &lt;asb.cpan@gmail.com&gt; wrote:<br/><br/>&gt; Hi!<br/>&gt; <br/>&gt; When creating the base for a new CPAN module using h2xs (e.g. with the<br/>&gt; command h2xs -b 5.10 -XA -n Super::Duper::Module), there is a lib folder<br/>&gt; created.<br/><br/>First of all, you should not use h2xs, but rather Dist-Zilla or Module-Starter<br/>( https://metacpan.org/release/Module-Starter ).<br/><br/>&gt; <br/>&gt; In this lib folder, the name space is mirrored by a directory tree (e.g.<br/>&gt; lib/Super/Duper/Module.ppm).<br/>&gt; <br/>&gt; Now, while browsing CPAN, I noticed some older modules not having a lib<br/>&gt; folder.<br/><br/>Yes, and it&#39;s a bad idea.<br/><br/>&gt; <br/>&gt; So, I personally like the lib folder because it&#39;s easy to identify where<br/>&gt; the module&#39;s code resides.<br/>&gt; <br/>&gt; But, is there any other advantage? Or to ask in another fashion: is it<br/>&gt; recommended to use a lib folder and if yes, why?<br/>&gt; <br/><br/>Using a lib folder makes everything ordered and nice, and allows you to do<br/>perl -Mblib or sometimes perl -Ilib / etc. and is good for good measure. NEVER<br/>Scatter your modules elsewhere.<br/><br/>Regards,<br/><br/> Shlomi Fish<br/><br/><br/>-- <br/>-----------------------------------------------------------------<br/>Shlomi Fish http://www.shlomifish.org/<br/>Beginners Site for the Vim text editor - http://vim.begin-site.org/<br/><br/>To have bugs is human; to find them &mdash; divine.<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/2014/10/msg124845.html Thu, 09 Oct 2014 08:22:42 +0000 Re: Best way to install perl modules by Shlomi Fish Hi Benjamin,<br/><br/>On Sun, 5 Oct 2014 17:39:46 +1300<br/>Benjamin Fernandis &lt;benjo11111@gmail.com&gt; wrote:<br/><br/>&gt; Hi Mike,<br/>&gt; <br/>&gt; Thanks for your kind response. I tried cpanm instead of cpan, but many<br/>&gt; times, it does not install require dependencies for module.<br/>&gt; <br/>&gt; For example, when i was trying to install<br/>&gt; cpanm XML::SAX -&gt; it failed and said no Fatal.pm module , then i manually<br/>&gt; first installed that module and then i tried to install XML::SAX and it<br/>&gt; works.<br/>&gt; <br/>&gt; It happens many times while installing different modules. I mean cpanm does<br/>&gt; not automatically fetch require dependencies for module. like yum in centos<br/>&gt; to install packages.<br/>&gt; <br/>&gt; Is there any tool or something like yum for perl module installations. Or<br/>&gt; Is there , I am missing anything ?<br/>&gt; <br/><br/>The equivalents of yum in the Perl-world are cpan/CPAN.pm and<br/>cpanp/CPANPLUS.pm . Also see what I wrote about it here:<br/><br/>* http://perl-begin.org/topics/cpan/<br/><br/>* http://perl-begin.org/topics/cpan/wrappers-for-distributions/<br/><br/>Note that the CentOS/RHEL/Fedora perl is suffering from several issues and the<br/>general wisdom is that you should install your own perl under a prefix using<br/>perlbrew - http://perlbrew.pl/ .<br/><br/>Regards,<br/><br/> Shlomi Fish<br/><br/><br/>-- <br/>-----------------------------------------------------------------<br/>Shlomi Fish http://www.shlomifish.org/<br/>Apple Inc. is Evil - http://www.shlomifish.org/open-source/anti/apple/<br/><br/>You can never truly appreciate The Gilmore Girls until you&rsquo;ve watched it in<br/>the original Klingon.<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/2014/10/msg124844.html Thu, 09 Oct 2014 08:12:52 +0000 Re: share a variable between files by Kent Fredric On 9 October 2014 08:36, Hans Ginzel &lt;hans@matfyz.cz&gt; wrote:<br/><br/>&gt; I want to use one global hash variable for options or configuration<br/>&gt; variables<br/>&gt; like verbose, debug. I don&#39;t want to pass them to each function<br/>&gt; or to almost each object.<br/>&gt;<br/><br/>Indeed, Jim Gibson explains you can simply declare &quot;our&quot; in both files and<br/>the variable gets shared.<br/><br/>Here is a contrived example that demonstrates that in a strange way:<br/><br/>https://gist.github.com/kentfredric/cc1ddaabd2c698139869<br/><br/>You&#39;ll see in this example two files are natively accessing the same<br/>variable. Its ugly, but it works.<br/><br/><br/>Though I&#39;d personally perfer something like this:<br/><br/>https://gist.github.com/kentfredric/28d4c7831c9012950db4<br/><br/>That is, having the variable declared with &quot;our&quot; in the namespace that uses<br/>it, and having everywhere else that needs to manipulate it use its fullly<br/>qualified name, %Alpha::Shared to change its values.<br/><br/>The difference would in practice be having code external to your main class<br/>doing<br/><br/>$class::opts{&#39;x&#39;} = &#39;y&#39;;<br/><br/>Instead of relying on the convoluition of having to have 2 distinct sets of<br/>code in the same namespace across 2 files.<br/><br/>Ideally I&#39;d opt to find a way to eliminate the global variables where it<br/>makes sense to, but for some tasks ( like global defaults ), there isn&#39;t<br/>many better ways, so making it as logically clean as possible is desirable.<br/><br/>( Apologies if you can&#39;t read github gist links, I find email a very poor<br/>medium for code examples )<br/><br/>-- <br/>Kent<br/><br/>*KENTNL* - https://metacpan.org/author/KENTNL<br/><br/> http://www.nntp.perl.org/group/perl.beginners/2014/10/msg124843.html Wed, 08 Oct 2014 20:10:43 +0000 Why to use a lib folder for a CPAN module by Alex Becker Hi!<br/><br/>When creating the base for a new CPAN module using h2xs (e.g. with the<br/>command h2xs -b 5.10 -XA -n Super::Duper::Module), there is a lib folder<br/>created.<br/><br/>In this lib folder, the name space is mirrored by a directory tree (e.g.<br/>lib/Super/Duper/Module.ppm).<br/><br/>Now, while browsing CPAN, I noticed some older modules not having a lib<br/>folder.<br/><br/>So, I personally like the lib folder because it&#39;s easy to identify where<br/>the module&#39;s code resides.<br/><br/>But, is there any other advantage? Or to ask in another fashion: is it<br/>recommended to use a lib folder and if yes, why?<br/><br/>Kind regards,<br/>Alex<br/><br/> http://www.nntp.perl.org/group/perl.beginners/2014/10/msg124842.html Wed, 08 Oct 2014 17:59:19 +0000 Re: share a variable between files by Jim Gibson The &lsquo;our&rsquo; statement associates a simple name with a package global variable in the current package. Therefore, if you want to make $var in file b.pl mean the package global variable $var in package a ($a:var), just put &lsquo;our $var;&rsquo; after the &lsquo;package a;&rsquo; statement in file b.pl (see below).<br/><br/>On Oct 8, 2014, at 7:35 AM, Hans Ginzel &lt;hans@matfyz.cz&gt; wrote:<br/><br/>&gt; Hello!<br/>&gt; <br/>&gt; Let&#39;s consider following strip-down example:<br/>&gt; <br/>&gt; # file a.pl<br/>&gt; use strict;<br/>&gt; package a;<br/>&gt; our $var=1;<br/>&gt; warn &quot;var=$var&quot;;<br/>&gt; <br/>&gt; # file b.pl<br/>&gt; use strict;<br/>&gt; #no strict qw/vars/;<br/>&gt; require &#39;b.pl&#39;;<br/>&gt; package a;<br/><br/>our $var;<br/><br/>&gt; warn &quot;var=$var&quot;;<br/>&gt; <br/>&gt; How to get rid of &quot;no strict qw/vars/;&quot; to not get message &quot;Global symbol<br/>&gt; &quot;$var&quot; requires explicit package name at b.pl&quot;, please? There is a package<br/>&gt; specification (&quot;package a;&quot;) in the b.pl file.<br/>&gt; <br/>&gt; Generally, I want to add a key to a global class hash variable (%opt)<br/>&gt; declared with our in a class module from another file.<br/>&gt; <br/>&gt; I realised, that there is possible without warning to define a subroutine<br/>&gt; in another package, but not to use a global variable from that package<br/>&gt; (=namespace).<br/><br/> http://www.nntp.perl.org/group/perl.beginners/2014/10/msg124841.html Wed, 08 Oct 2014 17:01:56 +0000 Re: share a variable between files by Kent Fredric On 9 October 2014 03:35, Hans Ginzel &lt;Hans@matfyz.cz&gt; wrote:<br/><br/>&gt; Hello!<br/>&gt;<br/>&gt; Let&#39;s consider following strip-down example:<br/>&gt;<br/>&gt; # file a.pl<br/>&gt; use strict;<br/>&gt; package a;<br/>&gt; our $var=1;<br/>&gt; warn &quot;var=$var&quot;;<br/>&gt;<br/>&gt; # file b.pl<br/>&gt; use strict;<br/>&gt; #no strict qw/vars/;<br/>&gt; require &#39;b.pl&#39;;<br/>&gt; package a;<br/>&gt; warn &quot;var=$var&quot;;<br/>&gt;<br/>&gt; How to get rid of &quot;no strict qw/vars/;&quot; to not get message &quot;Global symbol<br/>&gt; &quot;$var&quot; requires explicit package name at b.pl&quot;, please? There is a package<br/>&gt; specification (&quot;package a;&quot;) in the b.pl file.<br/>&gt;<br/>&gt; Generally, I want to add a key to a global class hash variable (%opt)<br/>&gt; declared with our in a class module from another file.<br/>&gt;<br/>&gt; I realised, that there is possible without warning to define a subroutine<br/>&gt; in another package, but not to use a global variable from that package<br/>&gt; (=namespace).<br/>&gt;<br/>&gt; Thank you<br/>&gt;<br/><br/>First, what are you trying to acheive.<br/><br/>Global variables are rarely a good idea, as is sharing variables between<br/>files.<br/><br/>So the question is, why are you trying to share a variable between files<br/>using globals?<br/><br/>My suggestion is you should be using an exporter of some kind, or<br/>qualifying the variables by name at very least.<br/><br/>Also, why are you *requiring* .pl files by string name? That is reasonably<br/>poor design and I would be interested in learning what educational material<br/>you are consuming that lead you to your current course of action so I can<br/>make a point of not recommending it =)<br/><br/><br/>-- <br/>Kent<br/><br/>*KENTNL* - https://metacpan.org/author/KENTNL<br/><br/> http://www.nntp.perl.org/group/perl.beginners/2014/10/msg124840.html Wed, 08 Oct 2014 14:50:11 +0000 share a variable between files by Hans Ginzel Hello!<br/><br/>Let&#39;s consider following strip-down example:<br/><br/># file a.pl<br/>use strict;<br/>package a;<br/>our $var=1;<br/>warn &quot;var=$var&quot;;<br/><br/># file b.pl<br/>use strict;<br/>#no strict qw/vars/;<br/>require &#39;b.pl&#39;;<br/>package a;<br/>warn &quot;var=$var&quot;;<br/><br/>How to get rid of &quot;no strict qw/vars/;&quot; to not get message &quot;Global symbol<br/>&quot;$var&quot; requires explicit package name at b.pl&quot;, please? There is a package<br/>specification (&quot;package a;&quot;) in the b.pl file.<br/><br/>Generally, I want to add a key to a global class hash variable (%opt)<br/>declared with our in a class module from another file.<br/><br/>I realised, that there is possible without warning to define a subroutine<br/>in another package, but not to use a global variable from that package<br/>(=namespace).<br/><br/>Thank you<br/>Hans<br/><br/> http://www.nntp.perl.org/group/perl.beginners/2014/10/msg124839.html Wed, 08 Oct 2014 14:37:11 +0000 Re: Best way to install perl modules by Kent Fredric On 7 October 2014 16:07, Benjamin Fernandis &lt;benjo11111@gmail.com&gt; wrote:<br/><br/>&gt; + Attaching log file.<br/>&gt;<br/><br/>Lacking Env.pm basically means your vendor&#39;s Perl is broken. Env.pm is<br/>shipped with Perl itself, and subsequently things may forget to depend on<br/>it ( at least, in a way that cpan tools recognise ) and be silently broken<br/>as a consequence.<br/><br/>It *might* be worth filing a bug with the respective packages saying &quot;hey,<br/>you need Env.pm, but dont depend on it&quot;<br/><br/>But the thing that will make life easiest for you is working out why you<br/>don&#39;t have things installed that are EXPECTED to be installed as part of a<br/>standard perl installation.<br/><br/>But the general problem is, sometimes people in Perl have external<br/>dependencies and forget to declare them as such.<br/><br/>When they do that, things break.<br/><br/>When things break like that, if you&#39;re sure the problem is them failing to<br/>declare the dependency, then you file a bug requesting they declare the<br/>dependency.<br/><br/>Once the dependency is declared, CPAN, CPANPLUS and cpanm will detect and<br/>respond to it.<br/><br/>-- <br/>Kent<br/><br/>*KENTNL* - https://metacpan.org/author/KENTNL<br/><br/> http://www.nntp.perl.org/group/perl.beginners/2014/10/msg124838.html Tue, 07 Oct 2014 03:19:59 +0000 Re: Best way to install perl modules by Benjamin Fernandis vim /root/.cpanm/work/1412646703.27571/build.log <br/>cpanm (App::cpanminus) 1.7012 on perl 5.016003 built for x86_64-linux-thread-multi <br/>Work directory is /root/.cpanm/work/1412646703.27571 <br/>You have make /usr/bin/make <br/>You have LWP 6.08 <br/>You have /usr/bin/tar: tar (GNU tar) 1.26 <br/>Copyright (C) 2011 Free Software Foundation, Inc. <br/>License GPLv3+: GNU GPL version 3 or later &lt;http://gnu.org/licenses/gpl.html&gt;. <br/>This is free software: you are free to change and redistribute it. <br/>You have /usr/bin/unzip <br/>Searching HTTP::Server::Simple on cpanmetadb ... <br/>--&gt; Working on HTTP::Server::Simple <br/>Fetching http://www.cpan.org/authors/id/J/JE/JESSE/HTTP-Server-Simple-0.44.tar.gz <br/>-&gt; OK <br/>Unpacking HTTP-Server-Simple-0.44.tar.gz <br/>Entering HTTP-Server-Simple-0.44 <br/>Checking configure dependencies from META.yml <br/>Checking if you have ExtUtils::MakeMaker 6.42 ... Yes (6.68) <br/>Configuring HTTP-Server-Simple-0.44 <br/>Running Makefile.PL <br/>Checking if your kit is complete... <br/>Looks good <br/>Writing Makefile for HTTP::Server::Simple <br/>Writing MYMETA.yml and MYMETA.json <br/>-&gt; OK <br/> ecking dependencies from MYMETA.json ... <br/>&#x25BD;hecking if you have Test::More 0 ... Yes (1.001006) <br/>Checking if you have ExtUtils::MakeMaker 6.42 ... Yes (6.68) <br/>Checking if you have CGI 0 ... Yes (4.04) <br/>Checking if you have Socket 0 ... Yes (2.010) <br/>Building and testing HTTP-Server-Simple-0.44 <br/>cp lib/HTTP/Server/Simple/CGI/Environment.pm blib/lib/HTTP/Server/Simple/CGI/Environment.pm <br/>cp lib/HTTP/Server/Simple.pm blib/lib/HTTP/Server/Simple.pm <br/>cp lib/HTTP/Server/Simple/CGI.pm blib/lib/HTTP/Server/Simple/CGI.pm <br/>Manifying blib/man3/HTTP::Server::Simple::CGI::Environment.3pm <br/>Manifying blib/man3/HTTP::Server::Simple.3pm <br/>Manifying blib/man3/HTTP::Server::Simple::CGI.3pm <br/>PERL_DL_NONLAZY=1 /usr/bin/perl &quot;-MExtUtils::Command::MM&quot; &quot;-e&quot; &quot;test_harness(0, &#39;inc&#39;, &#39;blib/lib&#39;, &#39;blib/arch&#39;)&quot; t/*.t <br/>t/00signature.t .... ok <br/>t/00smoke.t ........ ok <br/>t/01live.t ......... ok <br/>t/02pod.t .......... ok <br/>t/03podcoverage.t .. ok <br/>Can&#39;t locate Env.pm in @INC (@INC contains: /root/.cpanm/work/1412646703.27571/HTTP-Server-Simple-0.44/inc /root/.cpanm/work/1412646703.27571/HTTP-Server-Simple-0.44/bli <br/>b/lib /root/.cpanm/work/1412646703.27571/HTTP-Server-Simple-0.44/blib/arch /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/ve <br/>ndor_perl /usr/lib64/perl5 /usr/share/perl5 .) at t/04cgi.t line 140, &lt;DATA&gt; line 16. <br/>BEGIN failed--compilation aborted at t/04cgi.t line 140, &lt;DATA&gt; line 16. <br/>t/04cgi.t .......... <br/>Dubious, test returned 2 (wstat 512, 0x200) <br/>No subtests run <br/> <br/>Test Summary Report <br/>------------------- <br/>t/04cgi.t (Wstat: 512 Tests: 0 Failed: 0) <br/> Non-zero exit status: 2 <br/> Parse errors: No plan found in TAP output <br/>Files=6, Tests=29, 2 wallclock secs ( 0.02 usr 0.00 sys + 0.14 cusr 0.01 csys = 0.17 CPU) <br/>Result: FAIL <br/>Failed 1/6 test programs. 0/29 subtests failed. <br/>make: *** [test_dynamic] Error 2 <br/>-&gt; FAIL Installing HTTP::Server::Simple failed. See /root/.cpanm/work/1412646703.27571/build.log for details. Retry with --force to force install it. <br/>[root@kvm ~]# vim /root/.cpanm/work/1412646658.27040/build.log <br/>cpanm (App::cpanminus) 1.7012 on perl 5.016003 built for x86_64-linux-thread-multi <br/>Work directory is /root/.cpanm/work/1412646658.27040 <br/>You have make /usr/bin/make <br/>You have LWP 6.08 <br/>You have /usr/bin/tar: tar (GNU tar) 1.26 <br/>Copyright (C) 2011 Free Software Foundation, Inc. <br/>License GPLv3+: GNU GPL version 3 or later &lt;http://gnu.org/licenses/gpl.html&gt;. <br/>This is free software: you are free to change and redistribute it. <br/>You have /usr/bin/unzip <br/>Searching HTTP::Server::Simple on cpanmetadb ... <br/>--&gt; Working on HTTP::Server::Simple <br/>Fetching http://www.cpan.org/authors/id/J/JE/JESSE/HTTP-Server-Simple-0.44.tar.gz <br/>-&gt; OK <br/>Unpacking HTTP-Server-Simple-0.44.tar.gz <br/>Entering HTTP-Server-Simple-0.44 <br/>Checking configure dependencies from META.yml <br/>Checking if you have ExtUtils::MakeMaker 6.42 ... Yes (6.68) <br/>Configuring HTTP-Server-Simple-0.44 <br/>Running Makefile.PL <br/> ecking if your kit is complete... <br/>&#x25BD;ooks good <br/>Writing Makefile for HTTP::Server::Simple <br/>Writing MYMETA.yml and MYMETA.json <br/>-&gt; OK <br/>Checking dependencies from MYMETA.json ... <br/>Checking if you have Test::More 0 ... Yes (1.001006) <br/>Checking if you have ExtUtils::MakeMaker 6.42 ... Yes (6.68) <br/>Checking if you have CGI 0 ... Yes (4.04) <br/>Checking if you have Socket 0 ... Yes (2.010) <br/>Building and testing HTTP-Server-Simple-0.44 <br/>cp lib/HTTP/Server/Simple/CGI/Environment.pm blib/lib/HTTP/Server/Simple/CGI/Environment.pm <br/>cp lib/HTTP/Server/Simple.pm blib/lib/HTTP/Server/Simple.pm <br/>cp lib/HTTP/Server/Simple/CGI.pm blib/lib/HTTP/Server/Simple/CGI.pm <br/>Manifying blib/man3/HTTP::Server::Simple::CGI::Environment.3pm <br/>Manifying blib/man3/HTTP::Server::Simple.3pm <br/>Manifying blib/man3/HTTP::Server::Simple::CGI.3pm <br/>PERL_DL_NONLAZY=1 /usr/bin/perl &quot;-MExtUtils::Command::MM&quot; &quot;-e&quot; &quot;test_harness(0, &#39;inc&#39;, &#39;blib/lib&#39;, &#39;blib/arch&#39;)&quot; t/*.t <br/>t/00signature.t .... ok <br/>t/00smoke.t ........ ok <br/>t/01live.t ......... ok <br/>t/02pod.t .......... ok <br/>t/03podcoverage.t .. skipped: Test::Pod::Coverage 1.04 required for testing POD coverage <br/>Can&#39;t locate Env.pm in @INC (@INC contains: /root/.cpanm/work/1412646658.27040/HTTP-Server-Simple-0.44/inc /root/.cpanm/work/1412646658.27040/HTTP-Server-Simple-0.44/bli <br/>b/lib /root/.cpanm/work/1412646658.27040/HTTP-Server-Simple-0.44/blib/arch /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/ve <br/>ndor_perl /usr/lib64/perl5 /usr/share/perl5 .) at t/04cgi.t line 140, &lt;DATA&gt; line 16. <br/>BEGIN failed--compilation aborted at t/04cgi.t line 140, &lt;DATA&gt; line 16. <br/>t/04cgi.t .......... <br/>Dubious, test returned 2 (wstat 512, 0x200) <br/>No subtests run <br/> <br/>Test Summary Report <br/>------------------- <br/>t/04cgi.t (Wstat: 512 Tests: 0 Failed: 0) <br/> Non-zero exit status: 2 <br/> Parse errors: No plan found in TAP output <br/>[root@kvm ~]# vim /root/.cpanm/work/1412646658.27040/build.log <br/>Running Makefile.PL <br/>Checking if your kit is complete... <br/>Looks good <br/>Writing Makefile for HTTP::Server::Simple <br/>Writing MYMETA.yml and MYMETA.json <br/>-&gt; OK <br/>Checking dependencies from MYMETA.json ... <br/>Checking if you have Test::More 0 ... Yes (1.001006) <br/>Checking if you have ExtUtils::MakeMaker 6.42 ... Yes (6.68) <br/>Checking if you have CGI 0 ... Yes (4.04) <br/>Checking if you have Socket 0 ... Yes (2.010) <br/>Building and testing HTTP-Server-Simple-0.44 <br/>cp lib/HTTP/Server/Simple/CGI/Environment.pm blib/lib/HTTP/Server/Simple/CGI/Environment.pm <br/>cp lib/HTTP/Server/Simple.pm blib/lib/HTTP/Server/Simple.pm <br/>cp lib/HTTP/Server/Simple/CGI.pm blib/lib/HTTP/Server/Simple/CGI.pm <br/>Manifying blib/man3/HTTP::Server::Simple::CGI::Environment.3pm <br/>Manifying blib/man3/HTTP::Server::Simple.3pm <br/>Manifying blib/man3/HTTP::Server::Simple::CGI.3pm <br/>PERL_DL_NONLAZY=1 /usr/bin/perl &quot;-MExtUtils::Command::MM&quot; &quot;-e&quot; &quot;test_harness(0, &#39;inc&#39;, &#39;blib/lib&#39;, &#39;blib/arch&#39;)&quot; t/*.t <br/>t/00signature.t .... ok <br/>t/00smoke.t ........ ok <br/>t/01live.t ......... ok <br/>t/02pod.t .......... ok <br/>t/03podcoverage.t .. skipped: Test::Pod::Coverage 1.04 required for testing POD coverage <br/>Can&#39;t locate Env.pm in @INC (@INC contains: /root/.cpanm/work/1412646658.27040/HTTP-Server-Simple-0.44/inc /root/.cpanm/work/1412646658.27040/HTTP-Server-Simple-0.44/bli <br/>b/lib /root/.cpanm/work/1412646658.27040/HTTP-Server-Simple-0.44/blib/arch /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/ve <br/>ndor_perl /usr/lib64/perl5 /usr/share/perl5 .) at t/04cgi.t line 140, &lt;DATA&gt; line 16. <br/>BEGIN failed--compilation aborted at t/04cgi.t line 140, &lt;DATA&gt; line 16. <br/>t/04cgi.t .......... <br/>Dubious, test returned 2 (wstat 512, 0x200) <br/>No subtests run <br/> <br/>Test Summary Report <br/>------------------- <br/>t/04cgi.t (Wstat: 512 Tests: 0 Failed: 0) <br/> Non-zero exit status: 2 <br/> Parse errors: No plan found in TAP output <br/>[root@kvm ~]# <br/>[root@kvm ~]# c <br/>[root@kvm ~]# cat /root/.cpanm/work/1412646658.27040/build.log <br/>cpanm (App::cpanminus) 1.7012 on perl 5.016003 built for x86_64-linux-thread-multi <br/>Work directory is /root/.cpanm/work/1412646658.27040 <br/>You have make /usr/bin/make <br/>You have LWP 6.08 <br/>You have /usr/bin/tar: tar (GNU tar) 1.26 <br/>Copyright (C) 2011 Free Software Foundation, Inc. <br/>License GPLv3+: GNU GPL version 3 or later &lt;http://gnu.org/licenses/gpl.html&gt;. <br/>This is free software: you are free to change and redistribute it. <br/>There is NO WARRANTY, to the extent permitted by law. <br/> <br/>Written by John Gilmore and Jay Fenlason. <br/>You have /usr/bin/unzip <br/>Searching HTTP::Server::Simple on cpanmetadb ... <br/>--&gt; Working on HTTP::Server::Simple <br/>Fetching http://www.cpan.org/authors/id/J/JE/JESSE/HTTP-Server-Simple-0.44.tar.gz <br/>-&gt; OK <br/>Unpacking HTTP-Server-Simple-0.44.tar.gz <br/>Entering HTTP-Server-Simple-0.44 <br/>Checking configure dependencies from META.yml <br/>Checking if you have ExtUtils::MakeMaker 6.42 ... Yes (6.68) <br/>Configuring HTTP-Server-Simple-0.44 <br/>Running Makefile.PL <br/>Checking if your kit is complete... <br/>Looks good <br/>Writing Makefile for HTTP::Server::Simple <br/>Writing MYMETA.yml and MYMETA.json <br/>-&gt; OK <br/>Checking dependencies from MYMETA.json ... <br/>Checking if you have Test::More 0 ... Yes (1.001006) <br/>Checking if you have ExtUtils::MakeMaker 6.42 ... Yes (6.68) <br/>Checking if you have CGI 0 ... Yes (4.04) <br/>Checking if you have Socket 0 ... Yes (2.010) <br/>Building and testing HTTP-Server-Simple-0.44 <br/>cp lib/HTTP/Server/Simple/CGI/Environment.pm blib/lib/HTTP/Server/Simple/CGI/Environment.pm <br/>cp lib/HTTP/Server/Simple.pm blib/lib/HTTP/Server/Simple.pm <br/>cp lib/HTTP/Server/Simple/CGI.pm blib/lib/HTTP/Server/Simple/CGI.pm <br/>Manifying blib/man3/HTTP::Server::Simple::CGI::Environment.3pm <br/>Manifying blib/man3/HTTP::Server::Simple.3pm <br/>Manifying blib/man3/HTTP::Server::Simple::CGI.3pm <br/>PERL_DL_NONLAZY=1 /usr/bin/perl &quot;-MExtUtils::Command::MM&quot; &quot;-e&quot; &quot;test_harness(0, &#39;inc&#39;, &#39;blib/lib&#39;, &#39;blib/arch&#39;)&quot; t/*.t <br/>t/00signature.t .... ok <br/>t/00smoke.t ........ ok <br/>t/01live.t ......... ok <br/>t/02pod.t .......... ok <br/>t/03podcoverage.t .. skipped: Test::Pod::Coverage 1.04 required for testing POD coverage <br/>Can&#39;t locate Env.pm in @INC (@INC contains: /root/.cpanm/work/1412646658.27040/HTTP-Server-Simple-0.44/inc /root/.cpanm/work/1412646658.27040/HTTP-Server-Simple-0.44/blib/lib /root/.cpanm/work/1412646658.27040/HTTP-Server-Simple-0.44/blib/arch /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .) at t/04cgi.t line 140, &lt;DATA&gt; line 16. <br/>BEGIN failed--compilation aborted at t/04cgi.t line 140, &lt;DATA&gt; line 16. <br/>t/04cgi.t .......... <br/>Dubious, test returned 2 (wstat 512, 0x200) <br/>No subtests run <br/> <br/>Test Summary Report <br/>------------------- <br/>t/04cgi.t (Wstat: 512 Tests: 0 Failed: 0) <br/> Non-zero exit status: 2 <br/> Parse errors: No plan found in TAP output <br/>Files=6, Tests=26, 2 wallclock secs ( 0.02 usr 0.00 sys + 0.13 cusr 0.02 csys = 0.17 CPU) <br/>Result: FAIL <br/>Failed 1/6 test programs. 0/26 subtests failed. <br/>make: *** [test_dynamic] Error 2 <br/>-&gt; FAIL Installing HTTP::Server::Simple failed. See /root/.cpanm/work/1412646658.27040/build.log for details. Retry with --force to force install it. http://www.nntp.perl.org/group/perl.beginners/2014/10/msg124837.html Tue, 07 Oct 2014 03:07:27 +0000 Re: Best way to install perl modules by Mike Please provide us with any errors from the installation log you&#39;ve <br/>received when using cpanm.<br/><br/>On 10/06/2014 08:58 PM, Benjamin Fernandis wrote:<br/>&gt; Hi,<br/>&gt;<br/>&gt; Today I face same previous problem to install package with cpanm.<br/>&gt;<br/>&gt; This time i have already installed Development Tools as suggested by Sam.<br/>&gt;<br/>&gt;<br/>&gt; For testing it more, i was trying to install dancer by cpanm. First <br/>&gt; trial, i got failed and then looked into build log and found some <br/>&gt; dependent modules are not there so then i tried to first install them <br/>&gt; and those also have some more dependencies and then i have to resolve <br/>&gt; first from those and then step by step do install manually and lastly <br/>&gt; dancer installation works for me.<br/>&gt;<br/>&gt; Below is my manually package installation.<br/>&gt;<br/>&gt; Please suggest me to resolve this installation problem. Also suggest <br/>&gt; me if I am missing anything at OS level.<br/>&gt;<br/>&gt; OS : cenots 7<br/>&gt;<br/>&gt; Regards<br/>&gt; Ben<br/>&gt;<br/>&gt; cpanm Dancer<br/>&gt; 334<br/>&gt; 335 vim /root/.cpanm/work/1412646550.26687/build.log<br/>&gt; 336<br/>&gt; 337 cpanm HTTP::Server::Simple<br/>&gt; 338 vim /root/.cpanm/work/1412646612.26849/build.log<br/>&gt; 339 cpanm Test::Pod<br/>&gt; 340 cpanm HTTP::Server::Simple<br/>&gt; 341 vim /root/.cpanm/work/1412646658.27040/build.log<br/>&gt; 342 cpanm Test::Pod::Coverage<br/>&gt; 343 cpanm HTTP::Server::Simple<br/>&gt; 344 vim /root/.cpanm/work/1412646703.27571/build.log<br/>&gt; 345 cpanm HTTP::Server<br/>&gt; 346 cpanm Env<br/>&gt; 347 cpanm HTTP::Server::Simple<br/>&gt; 348 cpanm Dancer<br/>&gt; 349 instmodsh<br/>&gt; 350 history<br/>&gt;<br/>&gt; On Sun, Oct 5, 2014 at 6:17 PM, Benjamin Fernandis <br/>&gt; &lt;benjo11111@gmail.com &lt;mailto:benjo11111@gmail.com&gt;&gt; wrote:<br/>&gt;<br/>&gt; Hi, Sam,<br/>&gt;<br/>&gt; Thanks, After installing development tools group, it works.<br/>&gt;<br/>&gt; Regards<br/>&gt; Ben<br/>&gt;<br/>&gt; On Sun, Oct 5, 2014 at 6:02 PM, Sam &lt;perl@net153.net<br/>&gt; &lt;mailto:perl@net153.net&gt;&gt; wrote:<br/>&gt;<br/>&gt; You probably need to give us more info as both cpan and cpanm<br/>&gt; will auto resolve and install needed dependencies.<br/>&gt;<br/>&gt; The dependency installs could be failing because a compiler or<br/>&gt; something similar is missing.<br/>&gt;<br/>&gt; If you are on a redhat based system, trying running:<br/>&gt; yum groupinstall &quot;Development Tools&quot;<br/>&gt;<br/>&gt; If you are on a debian based system try running:<br/>&gt; aptitude install build-essential<br/>&gt;<br/>&gt;<br/>&gt; --Sam<br/>&gt;<br/>&gt;<br/>&gt; On 10/04/2014 11:39 PM, Benjamin Fernandis wrote:<br/>&gt;<br/>&gt; Hi Mike,<br/>&gt;<br/>&gt; Thanks for your kind response. I tried cpanm instead of<br/>&gt; cpan, but many<br/>&gt; times, it does not install require dependencies for module.<br/>&gt;<br/>&gt; For example, when i was trying to install<br/>&gt; cpanm XML::SAX -&gt; it failed and said no Fatal.pm module ,<br/>&gt; then i<br/>&gt; manually first installed that module and then i tried to<br/>&gt; install<br/>&gt; XML::SAX and it works.<br/>&gt;<br/>&gt; It happens many times while installing different modules.<br/>&gt; I mean cpanm<br/>&gt; does not automatically fetch require dependencies for<br/>&gt; module. like yum<br/>&gt; in centos to install packages.<br/>&gt;<br/>&gt; Is there any tool or something like yum for perl module<br/>&gt; installations.<br/>&gt; Or Is there , I am missing anything ?<br/>&gt;<br/>&gt; Regards<br/>&gt; Ben<br/>&gt;<br/>&gt; On Sun, Oct 5, 2014 at 2:51 PM, Mike<br/>&gt; &lt;ekimdunaway@gmail.com &lt;mailto:ekimdunaway@gmail.com&gt;<br/>&gt; &lt;mailto:ekimdunaway@gmail.com<br/>&gt; &lt;mailto:ekimdunaway@gmail.com&gt;&gt;&gt; wrote:<br/>&gt;<br/>&gt; Use cpanminus.<br/>&gt;<br/>&gt; To install:<br/>&gt;<br/>&gt; sudo curl -L http://cpanmin.us | perl - --sudo<br/>&gt; App::cpanminus<br/>&gt;<br/>&gt; To use: sudo cpanm &lt;module to install&gt;<br/>&gt;<br/>&gt; Here&#39;s the official documentation:<br/>&gt; http://search.cpan.org/~miyagawa/App-cpanminus-1.7012/lib/App/cpanminus.pm<br/>&gt; &lt;http://search.cpan.org/%7Emiyagawa/App-cpanminus-1.7012/lib/App/cpanminus.pm&gt;<br/>&gt;<br/>&gt;<br/>&gt; On 10/4/14, 8:32 PM, Benjamin Fernandis wrote:<br/>&gt;<br/>&gt; Hi,<br/>&gt;<br/>&gt; Many times I face problem with module installation<br/>&gt; and then have<br/>&gt; to go to google and apply trial and error to<br/>&gt; resolve this<br/>&gt; permanently, could u please suggest me best and<br/>&gt; correct method to<br/>&gt; get resolved it?<br/>&gt;<br/>&gt; i mean if i installed centos 7 freshly then what are<br/>&gt; pre-requisites from OS side to get perl module<br/>&gt; installation<br/>&gt; successfully. What steps require to follow?<br/>&gt;<br/>&gt; Previously i tried cpanm and cpan console but some<br/>&gt; times faced<br/>&gt; installation faild error.<br/>&gt;<br/>&gt; Is there any specific guideline to resolve this<br/>&gt; problem? I am<br/>&gt; using centos based distro.<br/>&gt;<br/>&gt; Regards<br/>&gt; Ben<br/>&gt;<br/>&gt;<br/>&gt;<br/>&gt;<br/>&gt;<br/>&gt; -- <br/>&gt; To unsubscribe, e-mail: beginners-unsubscribe@perl.org<br/>&gt; &lt;mailto:beginners-unsubscribe@perl.org&gt;<br/>&gt; For additional commands, e-mail: beginners-help@perl.org<br/>&gt; &lt;mailto:beginners-help@perl.org&gt;<br/>&gt; http://learn.perl.org/<br/>&gt;<br/>&gt;<br/>&gt;<br/>&gt;<br/><br/><br/> http://www.nntp.perl.org/group/perl.beginners/2014/10/msg124836.html Tue, 07 Oct 2014 02:00:06 +0000 Re: Best way to install perl modules by Benjamin Fernandis Hi,<br/><br/>Today I face same previous problem to install package with cpanm.<br/><br/>This time i have already installed Development Tools as suggested by Sam.<br/><br/><br/>For testing it more, i was trying to install dancer by cpanm. First trial,<br/>i got failed and then looked into build log and found some dependent<br/>modules are not there so then i tried to first install them and those also<br/>have some more dependencies and then i have to resolve first from those and<br/>then step by step do install manually and lastly dancer installation works<br/>for me.<br/><br/>Below is my manually package installation.<br/><br/>Please suggest me to resolve this installation problem. Also suggest me if<br/>I am missing anything at OS level.<br/><br/>OS : cenots 7<br/><br/>Regards<br/>Ben<br/><br/> cpanm Dancer<br/> 334<br/> 335 vim /root/.cpanm/work/1412646550.26687/build.log<br/> 336<br/> 337 cpanm HTTP::Server::Simple<br/> 338 vim /root/.cpanm/work/1412646612.26849/build.log<br/> 339 cpanm Test::Pod<br/> 340 cpanm HTTP::Server::Simple<br/> 341 vim /root/.cpanm/work/1412646658.27040/build.log<br/> 342 cpanm Test::Pod::Coverage<br/> 343 cpanm HTTP::Server::Simple<br/> 344 vim /root/.cpanm/work/1412646703.27571/build.log<br/> 345 cpanm HTTP::Server<br/> 346 cpanm Env<br/> 347 cpanm HTTP::Server::Simple<br/> 348 cpanm Dancer<br/> 349 instmodsh<br/> 350 history<br/><br/>On Sun, Oct 5, 2014 at 6:17 PM, Benjamin Fernandis &lt;benjo11111@gmail.com&gt;<br/>wrote:<br/><br/>&gt; Hi, Sam,<br/>&gt;<br/>&gt; Thanks, After installing development tools group, it works.<br/>&gt;<br/>&gt; Regards<br/>&gt; Ben<br/>&gt;<br/>&gt; On Sun, Oct 5, 2014 at 6:02 PM, Sam &lt;perl@net153.net&gt; wrote:<br/>&gt;<br/>&gt;&gt; You probably need to give us more info as both cpan and cpanm will auto<br/>&gt;&gt; resolve and install needed dependencies.<br/>&gt;&gt;<br/>&gt;&gt; The dependency installs could be failing because a compiler or something<br/>&gt;&gt; similar is missing.<br/>&gt;&gt;<br/>&gt;&gt; If you are on a redhat based system, trying running:<br/>&gt;&gt; yum groupinstall &quot;Development Tools&quot;<br/>&gt;&gt;<br/>&gt;&gt; If you are on a debian based system try running:<br/>&gt;&gt; aptitude install build-essential<br/>&gt;&gt;<br/>&gt;&gt;<br/>&gt;&gt; --Sam<br/>&gt;&gt;<br/>&gt;&gt;<br/>&gt;&gt; On 10/04/2014 11:39 PM, Benjamin Fernandis wrote:<br/>&gt;&gt;<br/>&gt;&gt;&gt; Hi Mike,<br/>&gt;&gt;&gt;<br/>&gt;&gt;&gt; Thanks for your kind response. I tried cpanm instead of cpan, but many<br/>&gt;&gt;&gt; times, it does not install require dependencies for module.<br/>&gt;&gt;&gt;<br/>&gt;&gt;&gt; For example, when i was trying to install<br/>&gt;&gt;&gt; cpanm XML::SAX -&gt; it failed and said no Fatal.pm module , then i<br/>&gt;&gt;&gt; manually first installed that module and then i tried to install<br/>&gt;&gt;&gt; XML::SAX and it works.<br/>&gt;&gt;&gt;<br/>&gt;&gt;&gt; It happens many times while installing different modules. I mean cpanm<br/>&gt;&gt;&gt; does not automatically fetch require dependencies for module. like yum<br/>&gt;&gt;&gt; in centos to install packages.<br/>&gt;&gt;&gt;<br/>&gt;&gt;&gt; Is there any tool or something like yum for perl module installations.<br/>&gt;&gt;&gt; Or Is there , I am missing anything ?<br/>&gt;&gt;&gt;<br/>&gt;&gt;&gt; Regards<br/>&gt;&gt;&gt; Ben<br/>&gt;&gt;&gt;<br/>&gt;&gt;&gt; On Sun, Oct 5, 2014 at 2:51 PM, Mike &lt;ekimdunaway@gmail.com<br/>&gt;&gt;&gt; &lt;mailto:ekimdunaway@gmail.com&gt;&gt; wrote:<br/>&gt;&gt;&gt;<br/>&gt;&gt;&gt; Use cpanminus.<br/>&gt;&gt;&gt;<br/>&gt;&gt;&gt; To install:<br/>&gt;&gt;&gt;<br/>&gt;&gt;&gt; sudo curl -L http://cpanmin.us | perl - --sudo App::cpanminus<br/>&gt;&gt;&gt;<br/>&gt;&gt;&gt; To use: sudo cpanm &lt;module to install&gt;<br/>&gt;&gt;&gt;<br/>&gt;&gt;&gt; Here&#39;s the official documentation:<br/>&gt;&gt;&gt; http://search.cpan.org/~miyagawa/App-cpanminus-1.7012/<br/>&gt;&gt;&gt; lib/App/cpanminus.pm<br/>&gt;&gt;&gt;<br/>&gt;&gt;&gt;<br/>&gt;&gt;&gt; On 10/4/14, 8:32 PM, Benjamin Fernandis wrote:<br/>&gt;&gt;&gt;<br/>&gt;&gt;&gt;&gt; Hi,<br/>&gt;&gt;&gt;&gt;<br/>&gt;&gt;&gt;&gt; Many times I face problem with module installation and then have<br/>&gt;&gt;&gt;&gt; to go to google and apply trial and error to resolve this<br/>&gt;&gt;&gt;&gt; permanently, could u please suggest me best and correct method to<br/>&gt;&gt;&gt;&gt; get resolved it?<br/>&gt;&gt;&gt;&gt;<br/>&gt;&gt;&gt;&gt; i mean if i installed centos 7 freshly then what are<br/>&gt;&gt;&gt;&gt; pre-requisites from OS side to get perl module installation<br/>&gt;&gt;&gt;&gt; successfully. What steps require to follow?<br/>&gt;&gt;&gt;&gt;<br/>&gt;&gt;&gt;&gt; Previously i tried cpanm and cpan console but some times faced<br/>&gt;&gt;&gt;&gt; installation faild error.<br/>&gt;&gt;&gt;&gt;<br/>&gt;&gt;&gt;&gt; Is there any specific guideline to resolve this problem? I am<br/>&gt;&gt;&gt;&gt; using centos based distro.<br/>&gt;&gt;&gt;&gt;<br/>&gt;&gt;&gt;&gt; Regards<br/>&gt;&gt;&gt;&gt; Ben<br/>&gt;&gt;&gt;&gt;<br/>&gt;&gt;&gt;<br/>&gt;&gt;&gt;<br/>&gt;&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/><br/> http://www.nntp.perl.org/group/perl.beginners/2014/10/msg124835.html Tue, 07 Oct 2014 01:58:12 +0000 Fwd: Edit and Print Hashes by Ken Slater On Mon, Oct 6, 2014 at 11:11 AM, Phil &lt;gammeeu@gmail.com&gt; wrote:<br/><br/>&gt; Hello There,<br/>&gt;<br/>&gt; I have a text file that is built up as follows:<br/>&gt;<br/>&gt; Naam;ISIN;Symbol;Market;Trading Currency<br/>&gt; IDI;FR0000051393;IDIP;Euronext Paris;EUR<br/>&gt; BETER BED;NL0000339703;BBED;Euronext Amsterdam;EUR<br/>&gt; ...<br/>&gt; GENTICEL;FR0011790542;GTCL;Euronext Paris,Brussels;EUR<br/>&gt;<br/>&gt; With the following code, I can read this text file into hashes:<br/>&gt; --------------------------<br/>&gt; use strict;<br/>&gt; use warnings;<br/>&gt;<br/>&gt; my %data;<br/>&gt; my @names;<br/>&gt;<br/>&gt;<br/>&gt; my $myFile = &quot;myfile.csv&quot;;<br/>&gt; open(FH, &#39;&lt;&#39;, $myFile) or error(&quot;Cannot open file ($!)&quot;);<br/>&gt;<br/>&gt; while (&lt;FH&gt;){<br/>&gt; chomp;<br/>&gt; my @list=split(&#39;;&#39;);<br/>&gt; for (my $i=0; $i&lt;=$#list; $i++){<br/>&gt; if ($.==1){<br/>&gt; $names[$i]=$list[$i];<br/>&gt; }<br/>&gt; else {<br/>&gt; push @{$data{$names[$i]}}, $list[$i];<br/>&gt; }<br/>&gt; }<br/>&gt; }<br/>&gt; close FH;<br/>&gt; --------------------------<br/>&gt; First Question:<br/>&gt;<br/>&gt; I wish to create an additional column/list which will be a combination of<br/>&gt; the &quot;Symbol&quot; and &quot;Market&quot;.<br/>&gt; The new column needs to contain the Symbol plus the one of the following<br/>&gt; cases:<br/>&gt; - Euronext Amsterdam ==&gt; append &quot;.PA&quot;<br/>&gt; - Euronext Brussels ==&gt; append &quot;.BR&quot;<br/>&gt; - Euronext Paris ==&gt; append &quot;.PA&quot;<br/>&gt;<br/>&gt; Second Question:<br/>&gt;<br/>&gt; How can I print all of the columns to a tab-delimited text file? The<br/>&gt; following are the headers of the (new) text file:<br/>&gt; Naam ISIN Symbol Ticker Market Trading Currency<br/>&gt;<br/>&gt;<br/>&gt;<br/>&gt; Thanks for your tips/help.<br/>&gt; Best regards<br/>&gt;<br/>&gt; Phil<br/>&gt;<br/><br/>Hi Phil,<br/><br/>In general, your code is fine. To nitpick, I would advise using lexical<br/>file handles (<br/>http://www.shlomifish.org/lecture/Perl/Newbies/lecture5/new-features/lexical-filehandles.html)<br/>rather than FH.<br/>Also, you usually do not have to use an indexed loop structure.<br/><br/>Below is an example that assumes you do not need to save the data, but<br/>rather read it in and print it out. These examples do not do any error<br/>checking.<br/><br/> use strict;<br/> use warnings;<br/><br/> my %map = ( &#39;Euronext Amsterdam&#39; =&gt; &#39;.AM&#39;,<br/> &#39;Euronext Brussels&#39; =&gt; &#39;.BR&#39;,<br/> &#39;Euronext Paris&#39; =&gt; &#39;.PA&#39;,<br/> );<br/><br/> # print output header line<br/> print &quot;Naam\tISIN\tSymbol\tTicker\tMarket\tTrading\tCurrency\n&quot;;<br/><br/> # Skip the header line<br/> &lt;DATA&gt;;<br/> while (&lt;DATA&gt;)<br/> {<br/> chomp;<br/> my ($name, $isin, $symbol, $market, $currency) = split(&#39;;&#39;);<br/> # If you wanted, do some error cheking to make sure none of the<br/> # fields are undef<br/> #<br/> # Could check to insure $map{$market} is defined<br/> my $ticker = &quot;$symbol$map{$market}&quot;;<br/> print &quot;$name\t$isin\t$symbol\t$ticker\t$market\t$currency\n&quot;<br/> }<br/><br/> __DATA__<br/> Naam;ISIN;Symbol;Market;Trading Currency<br/> IDI;FR0000051393;IDIP;Euronext Paris;EUR<br/> BETER BED;NL0000339703;BBED;Euronext Amsterdam;EUR<br/> GENTICEL;FR0011790542;GTCL;Euronext Brussels;EUR<br/><br/>If you need to store the data, the following provides an example.<br/>Note that it uses array slices to store the data. Of course there are many<br/>ways to do this in Perl. Also not that I shift the name off the array of<br/>fields rather than performing a check for the first element of the array.<br/><br/> use strict;<br/> use warnings;<br/><br/> my %data;<br/><br/> my %map = ( &#39;Euronext Amsterdam&#39; =&gt; &#39;.AM&#39;,<br/> &#39;Euronext Brussels&#39; =&gt; &#39;.BR&#39;,<br/> &#39;Euronext Paris&#39; =&gt; &#39;.PA&#39;,<br/> );<br/><br/> # print output header line<br/> print &quot;Naam\tISIN\tSymbol\tTicker\tMarket\tTrading\tCurrency\n&quot;;<br/><br/> # Skip the header line<br/> &lt;DATA&gt;;<br/> while (&lt;DATA&gt;)<br/> {<br/> chomp;<br/> my @list=split(&#39;;&#39;);<br/> my $name = shift @list;<br/> # Using array slices<br/> push @{$data{$name}}, @list[0..1];<br/> push @{$data{$name}}, &quot;$list[1]$map{$list[2]}&quot;;<br/> push @{$data{$name}}, @list[2..$#list];<br/> }<br/><br/> foreach my $name ( sort keys %data )<br/> {<br/> print join(&quot;\t&quot;, $name, @{$data{$name}}), &quot;\n&quot;;<br/> }<br/><br/> __DATA__<br/> Naam;ISIN;Symbol;Market;Trading Currency<br/> IDI;FR0000051393;IDIP;Euronext Paris;EUR<br/> BETER BED;NL0000339703;BBED;Euronext Amsterdam;EUR<br/> GENTICEL;FR0011790542;GTCL;Euronext Brussels;EUR<br/><br/><br/>HTH, Ken<br/><br/> http://www.nntp.perl.org/group/perl.beginners/2014/10/msg124834.html Tue, 07 Oct 2014 00:16:04 +0000 Re: Problem with regex by John Delacour <br/>&gt; On 6 Oct 2014, at 18:57, punit jain &lt;contactpunitjain@gmail.com&gt; wrote:<br/>&gt; <br/>&gt; Thanks Paul. However I think I couldnot explain the problem.<br/>&gt; <br/>&gt; The issue is when I have mailid&#39;s as well as a part of input stream.<br/>&gt; <br/>&gt; Input stream ---&gt; $str=&quot;ldap:///uid=user1,ou=People,o=test.com &lt;http://test.com/&gt;,abc@test.com &lt;mailto:abc@test.com&gt;,tt@test.com &lt;mailto:tt@test.com&gt;,rr@test.com &lt;mailto:rr@test.com&gt;,ldap:///uid=user2,ou=People,o=test.com &lt;http://test.com/&gt;,ldap:///uid=user3,ou=People,o=test.com &lt;http://test.com/&gt;&quot;<br/><br/>Suddenly you&#39;ve switched to double quotes. That won&#39;t do unless you escape the @s.<br/><br/>&gt; expected output<br/>&gt; ============<br/>&gt; first=uid=user1,ou=People,o=test.com &lt;http://test.com/&gt;<br/>&gt; first=abc@test.com &lt;mailto:abc@test.com&gt;<br/>&gt; first=tt@test.com &lt;mailto:tt@test.com&gt;<br/>&gt; first=rr@test.com &lt;mailto:rr@test.com&gt;<br/>&gt; first = uid=user2,ou=People,o=test.com &lt;http://test.com/&gt;<br/>&gt; first = uid=user3,ou=People,o=test.com &lt;http://test.com/&gt;<br/><br/>Try this.<br/><br/>#!/usr/bin/perl<br/>use strict;<br/>my $str =&#39;ldap:///uid=user1,ou=People,o=test.com,abc@test.com,tt@test.com,rr@test.com,ldap:///uid=user2,ou=People,o=test.com,ldap:///uid=user3,ou=People,o=test.com&#39;;<br/>my @ldap = split &#39;ldap:///&#39;, $str;<br/>my $concat;<br/>for (@ldap){<br/> for (split /,/) {<br/> if (/\@/) {<br/> $concat .= &quot;\nfirst=$_&quot;<br/> } elsif (/uid/) {<br/> $concat .= &quot;\nfirst=$_,&quot;<br/> } else {<br/> $concat .= &quot;$_,&quot;<br/> }<br/> }<br/>}<br/>my @printlist = split /\n/, $concat;<br/>for (@printlist) {<br/> unless (/^$/){ # skip empty lines<br/> s~,$~~g; # remove trailing commas<br/> print &quot;$_\n&quot;;<br/> }<br/>}<br/><br/><br/>#JD<br/><br/><br/><br/><br/> http://www.nntp.perl.org/group/perl.beginners/2014/10/msg124833.html Mon, 06 Oct 2014 22:31:43 +0000 Edit and Print Hashes by Phil Hello There,<br/><br/>I have a text file that is built up as follows:<br/><br/>Naam;ISIN;Symbol;Market;Trading Currency<br/>IDI;FR0000051393;IDIP;Euronext Paris;EUR<br/>BETER BED;NL0000339703;BBED;Euronext Amsterdam;EUR<br/>...<br/>GENTICEL;FR0011790542;GTCL;Euronext Paris,Brussels;EUR<br/><br/>With the following code, I can read this text file into hashes:<br/>--------------------------<br/>use strict;<br/>use warnings;<br/> <br/>my %data;<br/>my @names;<br/><br/><br/>my $myFile = &quot;myfile.csv&quot;;<br/>open(FH, &#39;&lt;&#39;, $myFile) or error(&quot;Cannot open file ($!)&quot;);<br/><br/>while (&lt;FH&gt;){<br/> chomp;<br/> my @list=split(&#39;;&#39;);<br/> for (my $i=0; $i&lt;=$#list; $i++){<br/> if ($.==1){<br/> $names[$i]=$list[$i];<br/> }<br/> else {<br/> push @{$data{$names[$i]}}, $list[$i];<br/> }<br/> }<br/>}<br/>close FH;<br/>--------------------------<br/>First Question:<br/><br/>I wish to create an additional column/list which will be a combination <br/>of the &quot;Symbol&quot; and &quot;Market&quot;.<br/>The new column needs to contain the Symbol plus the one of the following cases:<br/>- Euronext Amsterdam ==&gt; append &quot;.PA&quot;<br/>- Euronext Brussels ==&gt; append &quot;.BR&quot;<br/>- Euronext Paris ==&gt; append &quot;.PA&quot;<br/><br/>Second Question:<br/><br/>How can I print all of the columns to a tab-delimited text file? The <br/>following are the headers of the (new) text file:<br/>Naam ISIN Symbol Ticker Market Trading Currency<br/><br/><br/><br/>Thanks for your tips/help.<br/>Best regards<br/><br/>Phil<br/><br/><br/> http://www.nntp.perl.org/group/perl.beginners/2014/10/msg124832.html Mon, 06 Oct 2014 22:10:11 +0000 Re: Problem with regex by punit jain Thanks Paul. However I think I couldnot explain the problem.<br/><br/>The issue is when I have mailid&#39;s as well as a part of input stream.<br/><br/> Input stream ---&gt; $str=&quot;ldap:///uid=user1,ou=People,o=test.com,abc@test.com<br/>,tt@test.com,rr@test.com,ldap:///uid=user2,ou=People,o=test.com<br/>,ldap:///uid=user3,ou=People,o=test.com&quot;<br/><br/>current output<br/>===========<br/>*first = uid=user1,ou=People,o=test.com &lt;http://test.com&gt;,abc@test.com<br/>&lt;abc@test.com&gt;,tt@test.com &lt;tt@test.com&gt;,rr@test.com &lt;rr@test.com&gt;*<br/>first = uid=user2,ou=People,o=test.com<br/>first = uid=user3,ou=People,o=test.com<br/><br/>expected output<br/>============<br/>first=uid=user1,ou=People,o=test.com<br/>first=abc@test.com<br/>first=tt@test.com<br/>first=rr@test.com<br/>first = uid=user2,ou=People,o=test.com<br/>first = uid=user3,ou=People,o=test.com<br/><br/>Regards,<br/>Punit<br/><br/> http://www.nntp.perl.org/group/perl.beginners/2014/10/msg124831.html Mon, 06 Oct 2014 17:57:33 +0000 Re: Problem with regex by Paul Johnson On Mon, Oct 06, 2014 at 09:34:15PM +0530, punit jain wrote:<br/>&gt; Hi,<br/>&gt; <br/>&gt; I have a regex problem. My current working program is like this :-<br/>&gt; <br/>&gt; <br/>&gt; #!/usr/bin/perl<br/>&gt; <br/>&gt; *$str=&#39;ldap:///uid=user1,ou=People,o=test.com<br/>&gt; &lt;http://test.com&gt;,mailto:user4@test.com<br/>&gt; &lt;user4@test.com&gt;,ldap:///uid=user2,ou=People,o=test.com<br/>&gt; &lt;http://test.com&gt;,ldap:///uid=user3,ou=People,o=test.com<br/>&gt; &lt;http://test.com&gt;&#39;;*<br/>&gt; <br/>&gt; while($str=~/^(?:mailto:|ldap:\/\/\/)(.*?),(?:mailto:|ldap:\/\/\/)/){<br/>&gt; print &quot;first = $1&quot;.&quot;\n&quot;;<br/>&gt; <br/>&gt; # Process user for send email<br/>&gt; ProcessUser($first);<br/>&gt; if($str =~ /^(?:ldap:\/\/\/.+?|mailto:.+?),(ldap.*|mailto.*)/) {<br/>&gt; print &quot;remain = $1&quot;.&quot;\n&quot;;<br/>&gt; $str=$1;<br/>&gt; }<br/>&gt; }<br/>&gt; <br/>&gt; However when I have input string as :-<br/>&gt; <br/>&gt; &#39;ldap:///uid=user1,ou=People,o=test.com,abc@test.com*,tt@test.com<br/>&gt; &lt;tt@test.com&gt;,rr@test.com &lt;rr@test.com&gt;*,ldap:///uid=user2,ou=People,o=<br/>&gt; test.com,ldap:///uid=user3,ou=People,o=test.com&#39;<br/>&gt; <br/>&gt; it breaks. I tried multiple regex, however could not get it working.<br/>&gt; Any clue on regex changes to accomodate this ?<br/><br/>First, pay attention to what Kent has written.<br/><br/>But to get to specific problems:<br/><br/>I think you are misunderstanding how to use while with a regex match.<br/>You don&#39;t need to replace the string with the unmatched part - perl will<br/>handle that sort of low-level messing about for you. You just need to<br/>use the /g flag and the next match will start off where the previous one<br/>finished.<br/><br/>To get this to work, don&#39;t anchor your regex to the start of the string,<br/>or you&#39;ll only get one match.<br/><br/>Also, your check that you are only matching up to the next mailto or<br/>ldap section needs to ensure that it doesn&#39;t consume that part of the<br/>string. This is done by using a positive lookahead assertion (?=).<br/><br/>Then you need to allow for matching the last part of the string, which<br/>will not be followed by another part to match.<br/><br/>Finally, it looks like you have newline characters in your input. If<br/>that is the case then you need to add the /s flag so that . will also<br/>match a newline.<br/><br/>And for style, you can pull out the duplicated parts of the regex and<br/>use another delimiter to avoid Leaning Toothpick Syndrome.<br/><br/>Putting it together you get:<br/><br/> my $start = qr!mailto:|ldap:///!;<br/> while ($str =~ /$start(.*?)(?=,$start|$)/sg) {<br/> print &quot;first = $1\n&quot;;<br/> }<br/><br/>Or you could avoid the messing about with the while condition and use<br/>split:<br/><br/> say for split $start, $str;<br/><br/>-- <br/>Paul Johnson - paul@pjcj.net<br/>http://www.pjcj.net<br/> http://www.nntp.perl.org/group/perl.beginners/2014/10/msg124830.html Mon, 06 Oct 2014 17:30:51 +0000 Re: Problem with regex by Kent Fredric On 7 October 2014 05:04, punit jain &lt;contactpunitjain@gmail.com&gt; wrote:<br/><br/>&gt; it breaks. I tried multiple regex, however could not get it working.<br/>&gt; Any clue on regex changes to accomodate this ?<br/>&gt;<br/>&gt;<br/>1. You said you have a regex, and that you can&#39;t get it working, but what<br/>is it that isn&#39;t working?<br/>2. This might not be applicable to your problem, but you code lacks<br/>&#39;strict&#39; and &#39;warnings&#39;. Turning both of those on usually helps expose<br/>many kinds of silent bugs.<br/>3. What is the source of your string?<br/>4. Is it intended to be many ldap strings seperated by commas, or a single<br/>ldap URI where one has an attribute called &quot;ldap://uid&quot; ( ie: your string<br/>appears vaugely like a valid single LDAP string<br/>http://tools.ietf.org/html/rfc2255#section-3 )<br/><br/><br/><br/>----<br/>use strict;<br/>use warnings;<br/><br/>use URI;<br/>my $str = &#39;ldap:///uid=user1,ou=People,o=test.com,mailto:user4@test.com<br/>,ldap:///uid=user2,ou=People,o=test.com,ldap:///uid=user3,ou=People,o=<br/>test.com&#39;;<br/><br/>my $uri = URI-&gt;new( $str );<br/>print $uri-&gt;dn; # uid=user1,ou=People,o=test.com,mailto:user4@test.com<br/>,ldap:///uid=user2,ou=People,o=test.com,ldap:///uid=user3,ou=People,o=<br/>test.com<br/><br/>---<br/><br/><br/><br/><br/><br/><br/>-- <br/>Kent<br/><br/>*KENTNL* - https://metacpan.org/author/KENTNL<br/><br/> http://www.nntp.perl.org/group/perl.beginners/2014/10/msg124829.html Mon, 06 Oct 2014 16:19:09 +0000 Problem with regex by punit jain Hi,<br/><br/>I have a regex problem. My current working program is like this :-<br/><br/><br/>#!/usr/bin/perl<br/><br/>*$str=&#39;ldap:///uid=user1,ou=People,o=test.com<br/>&lt;http://test.com&gt;,mailto:user4@test.com<br/>&lt;user4@test.com&gt;,ldap:///uid=user2,ou=People,o=test.com<br/>&lt;http://test.com&gt;,ldap:///uid=user3,ou=People,o=test.com<br/>&lt;http://test.com&gt;&#39;;*<br/><br/>while($str=~/^(?:mailto:|ldap:\/\/\/)(.*?),(?:mailto:|ldap:\/\/\/)/){<br/>print &quot;first = $1&quot;.&quot;\n&quot;;<br/><br/> # Process user for send email<br/> ProcessUser($first);<br/> if($str =~ /^(?:ldap:\/\/\/.+?|mailto:.+?),(ldap.*|mailto.*)/) {<br/>print &quot;remain = $1&quot;.&quot;\n&quot;;<br/>$str=$1;<br/>}<br/>}<br/><br/>However when I have input string as :-<br/><br/>&#39;ldap:///uid=user1,ou=People,o=test.com,abc@test.com*,tt@test.com<br/>&lt;tt@test.com&gt;,rr@test.com &lt;rr@test.com&gt;*,ldap:///uid=user2,ou=People,o=<br/>test.com,ldap:///uid=user3,ou=People,o=test.com&#39;<br/><br/>it breaks. I tried multiple regex, however could not get it working.<br/>Any clue on regex changes to accomodate this ?<br/><br/><br/>Regards,<br/>Punit<br/><br/> http://www.nntp.perl.org/group/perl.beginners/2014/10/msg124828.html Mon, 06 Oct 2014 16:04:26 +0000 Re: Best way to install perl modules by Benjamin Fernandis Hi, Sam,<br/><br/>Thanks, After installing development tools group, it works.<br/><br/>Regards<br/>Ben<br/><br/>On Sun, Oct 5, 2014 at 6:02 PM, Sam &lt;perl@net153.net&gt; wrote:<br/><br/>&gt; You probably need to give us more info as both cpan and cpanm will auto<br/>&gt; resolve and install needed dependencies.<br/>&gt;<br/>&gt; The dependency installs could be failing because a compiler or something<br/>&gt; similar is missing.<br/>&gt;<br/>&gt; If you are on a redhat based system, trying running:<br/>&gt; yum groupinstall &quot;Development Tools&quot;<br/>&gt;<br/>&gt; If you are on a debian based system try running:<br/>&gt; aptitude install build-essential<br/>&gt;<br/>&gt;<br/>&gt; --Sam<br/>&gt;<br/>&gt;<br/>&gt; On 10/04/2014 11:39 PM, Benjamin Fernandis wrote:<br/>&gt;<br/>&gt;&gt; Hi Mike,<br/>&gt;&gt;<br/>&gt;&gt; Thanks for your kind response. I tried cpanm instead of cpan, but many<br/>&gt;&gt; times, it does not install require dependencies for module.<br/>&gt;&gt;<br/>&gt;&gt; For example, when i was trying to install<br/>&gt;&gt; cpanm XML::SAX -&gt; it failed and said no Fatal.pm module , then i<br/>&gt;&gt; manually first installed that module and then i tried to install<br/>&gt;&gt; XML::SAX and it works.<br/>&gt;&gt;<br/>&gt;&gt; It happens many times while installing different modules. I mean cpanm<br/>&gt;&gt; does not automatically fetch require dependencies for module. like yum<br/>&gt;&gt; in centos to install packages.<br/>&gt;&gt;<br/>&gt;&gt; Is there any tool or something like yum for perl module installations.<br/>&gt;&gt; Or Is there , I am missing anything ?<br/>&gt;&gt;<br/>&gt;&gt; Regards<br/>&gt;&gt; Ben<br/>&gt;&gt;<br/>&gt;&gt; On Sun, Oct 5, 2014 at 2:51 PM, Mike &lt;ekimdunaway@gmail.com<br/>&gt;&gt; &lt;mailto:ekimdunaway@gmail.com&gt;&gt; wrote:<br/>&gt;&gt;<br/>&gt;&gt; Use cpanminus.<br/>&gt;&gt;<br/>&gt;&gt; To install:<br/>&gt;&gt;<br/>&gt;&gt; sudo curl -L http://cpanmin.us | perl - --sudo App::cpanminus<br/>&gt;&gt;<br/>&gt;&gt; To use: sudo cpanm &lt;module to install&gt;<br/>&gt;&gt;<br/>&gt;&gt; Here&#39;s the official documentation:<br/>&gt;&gt; http://search.cpan.org/~miyagawa/App-cpanminus-1.7012/<br/>&gt;&gt; lib/App/cpanminus.pm<br/>&gt;&gt;<br/>&gt;&gt;<br/>&gt;&gt; On 10/4/14, 8:32 PM, Benjamin Fernandis wrote:<br/>&gt;&gt;<br/>&gt;&gt;&gt; Hi,<br/>&gt;&gt;&gt;<br/>&gt;&gt;&gt; Many times I face problem with module installation and then have<br/>&gt;&gt;&gt; to go to google and apply trial and error to resolve this<br/>&gt;&gt;&gt; permanently, could u please suggest me best and correct method to<br/>&gt;&gt;&gt; get resolved it?<br/>&gt;&gt;&gt;<br/>&gt;&gt;&gt; i mean if i installed centos 7 freshly then what are<br/>&gt;&gt;&gt; pre-requisites from OS side to get perl module installation<br/>&gt;&gt;&gt; successfully. What steps require to follow?<br/>&gt;&gt;&gt;<br/>&gt;&gt;&gt; Previously i tried cpanm and cpan console but some times faced<br/>&gt;&gt;&gt; installation faild error.<br/>&gt;&gt;&gt;<br/>&gt;&gt;&gt; Is there any specific guideline to resolve this problem? I am<br/>&gt;&gt;&gt; using centos based distro.<br/>&gt;&gt;&gt;<br/>&gt;&gt;&gt; Regards<br/>&gt;&gt;&gt; Ben<br/>&gt;&gt;&gt;<br/>&gt;&gt;<br/>&gt;&gt;<br/>&gt;&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/> http://www.nntp.perl.org/group/perl.beginners/2014/10/msg124827.html Sun, 05 Oct 2014 05:17:15 +0000 Re: Best way to install perl modules by Sam You probably need to give us more info as both cpan and cpanm will auto <br/>resolve and install needed dependencies.<br/><br/>The dependency installs could be failing because a compiler or something <br/>similar is missing.<br/><br/>If you are on a redhat based system, trying running:<br/>yum groupinstall &quot;Development Tools&quot;<br/><br/>If you are on a debian based system try running:<br/>aptitude install build-essential<br/><br/><br/>--Sam<br/><br/><br/>On 10/04/2014 11:39 PM, Benjamin Fernandis wrote:<br/>&gt; Hi Mike,<br/>&gt;<br/>&gt; Thanks for your kind response. I tried cpanm instead of cpan, but many<br/>&gt; times, it does not install require dependencies for module.<br/>&gt;<br/>&gt; For example, when i was trying to install<br/>&gt; cpanm XML::SAX -&gt; it failed and said no Fatal.pm module , then i<br/>&gt; manually first installed that module and then i tried to install<br/>&gt; XML::SAX and it works.<br/>&gt;<br/>&gt; It happens many times while installing different modules. I mean cpanm<br/>&gt; does not automatically fetch require dependencies for module. like yum<br/>&gt; in centos to install packages.<br/>&gt;<br/>&gt; Is there any tool or something like yum for perl module installations.<br/>&gt; Or Is there , I am missing anything ?<br/>&gt;<br/>&gt; Regards<br/>&gt; Ben<br/>&gt;<br/>&gt; On Sun, Oct 5, 2014 at 2:51 PM, Mike &lt;ekimdunaway@gmail.com<br/>&gt; &lt;mailto:ekimdunaway@gmail.com&gt;&gt; wrote:<br/>&gt;<br/>&gt; Use cpanminus.<br/>&gt;<br/>&gt; To install:<br/>&gt;<br/>&gt; sudo curl -L http://cpanmin.us | perl - --sudo App::cpanminus<br/>&gt;<br/>&gt; To use: sudo cpanm &lt;module to install&gt;<br/>&gt;<br/>&gt; Here&#39;s the official documentation:<br/>&gt; http://search.cpan.org/~miyagawa/App-cpanminus-1.7012/lib/App/cpanminus.pm<br/>&gt;<br/>&gt;<br/>&gt; On 10/4/14, 8:32 PM, Benjamin Fernandis wrote:<br/>&gt;&gt; Hi,<br/>&gt;&gt;<br/>&gt;&gt; Many times I face problem with module installation and then have<br/>&gt;&gt; to go to google and apply trial and error to resolve this<br/>&gt;&gt; permanently, could u please suggest me best and correct method to<br/>&gt;&gt; get resolved it?<br/>&gt;&gt;<br/>&gt;&gt; i mean if i installed centos 7 freshly then what are<br/>&gt;&gt; pre-requisites from OS side to get perl module installation<br/>&gt;&gt; successfully. What steps require to follow?<br/>&gt;&gt;<br/>&gt;&gt; Previously i tried cpanm and cpan console but some times faced<br/>&gt;&gt; installation faild error.<br/>&gt;&gt;<br/>&gt;&gt; Is there any specific guideline to resolve this problem? I am<br/>&gt;&gt; using centos based distro.<br/>&gt;&gt;<br/>&gt;&gt; Regards<br/>&gt;&gt; Ben<br/>&gt;<br/>&gt;<br/><br/> http://www.nntp.perl.org/group/perl.beginners/2014/10/msg124826.html Sun, 05 Oct 2014 05:02:23 +0000 Re: Best way to install perl modules by Benjamin Fernandis Hi Mike,<br/><br/>Thanks for your kind response. I tried cpanm instead of cpan, but many<br/>times, it does not install require dependencies for module.<br/><br/>For example, when i was trying to install<br/>cpanm XML::SAX -&gt; it failed and said no Fatal.pm module , then i manually<br/>first installed that module and then i tried to install XML::SAX and it<br/>works.<br/><br/>It happens many times while installing different modules. I mean cpanm does<br/>not automatically fetch require dependencies for module. like yum in centos<br/>to install packages.<br/><br/>Is there any tool or something like yum for perl module installations. Or<br/>Is there , I am missing anything ?<br/><br/>Regards<br/>Ben<br/><br/>On Sun, Oct 5, 2014 at 2:51 PM, Mike &lt;ekimdunaway@gmail.com&gt; wrote:<br/><br/>&gt; Use cpanminus.<br/>&gt;<br/>&gt; To install:<br/>&gt;<br/>&gt; sudo curl -L http://cpanmin.us | perl - --sudo App::cpanminus<br/>&gt;<br/>&gt; To use: sudo cpanm &lt;module to install&gt;<br/>&gt;<br/>&gt; Here&#39;s the official documentation:<br/>&gt; http://search.cpan.org/~miyagawa/App-cpanminus-1.7012/lib/App/cpanminus.pm<br/>&gt;<br/>&gt;<br/>&gt; On 10/4/14, 8:32 PM, Benjamin Fernandis wrote:<br/>&gt;<br/>&gt; Hi,<br/>&gt;<br/>&gt; Many times I face problem with module installation and then have to go<br/>&gt; to google and apply trial and error to resolve this permanently, could u<br/>&gt; please suggest me best and correct method to get resolved it?<br/>&gt;<br/>&gt; i mean if i installed centos 7 freshly then what are pre-requisites from<br/>&gt; OS side to get perl module installation successfully. What steps require to<br/>&gt; follow?<br/>&gt;<br/>&gt; Previously i tried cpanm and cpan console but some times faced<br/>&gt; installation faild error.<br/>&gt;<br/>&gt; Is there any specific guideline to resolve this problem? I am using<br/>&gt; centos based distro.<br/>&gt;<br/>&gt; Regards<br/>&gt; Ben<br/>&gt;<br/>&gt;<br/>&gt;<br/><br/> http://www.nntp.perl.org/group/perl.beginners/2014/10/msg124825.html Sun, 05 Oct 2014 04:39:57 +0000