From anotheranne at fables.co.za Mon May 2 04:47:12 2011 From: anotheranne at fables.co.za (Anne Wainwright) Date: Mon, 2 May 2011 13:47:12 +0200 Subject: [za-pm] Introducing Darryl Trimming ... with a regex /x modifier problem Message-ID: <20110502134712.575481d3@ubuntu-laptop> ... and who has just stumped me short of rereading my Friedl. I have subscribed him to the list just now so he will benefit from your list posts. Darryl, are you using regex-coach (a windows thing) which I have always found the best playground for sorting out regular expressions that don't do what you tell them? bestest anne Begin forwarded message: Date: Mon, 2 May 2011 13:15:54 +0200 From: "Darryl Trimming" To: Subject: perl help? Hi Anne I've just started learning perl, and found your contact details here (http://www.pm.org/groups/522.html) while looking for community help. It seems a bit out of date, so please forgive me if I'm knocking on the wrong door. I was exploring the "/x" regexp modifier, and came upon some unexpected results. Upon closer inspection, my problem lies with the ternary operator. I can't see why the following results are inconsistent .. say '1:'.( 'hello' =~ /h e l l o/ )?'true':'false'; # no '/x', no match say '2:'.( 'hello' =~ /h e l l o/x )?'true':'false'; # '/x' ignores spaces, produces '1' say '3:'.( 'h e l l o' =~ /h e l l o/x )?'true':'false'; # '/x' ignores spaces, no match say '1:'.( 'hello' =~ /h e l l o/ ).'.'; # no '/x', no match say '2:'.( 'hello' =~ /h e l l o/x ).'.'; # '/x' ignores spaces, produces '1' say '3:'.( 'h e l l o' =~ /h e l l o/x ).'.'; # '/x' ignores spaces, no match say '1:'.( 'hello' =~ /h e l l o/ ) && 'true.'; # no '/x', no match say '2:'.( 'hello' =~ /h e l l o/x ) && 'true.'; # '/x' ignores spaces, produces '1' say '3:'.( 'h e l l o' =~ /h e l l o/x ) && 'true.'; # '/x' ignores spaces, no match say '1:'.(( 'hello' =~ /h e l l o/ ) + 0) .'.'; # no '/x', no match say '2:'.(( 'hello' =~ /h e l l o/x ) + 0) .'.'; # '/x' ignores spaces, produces '1' say '3:'.(( 'h e l l o' =~ /h e l l o/x ) + 0) .'.'; # '/x' ignores spaces, no match say '1:'.(( 'hello' =~ /h e l l o/ ) + 0)?'true':'false'; # no '/x', no match say '2:'.(( 'hello' =~ /h e l l o/x ) + 0)?'true':'false'; # '/x' ignores spaces, produces '1' say '3:'.(( 'h e l l o' =~ /h e l l o/x ) + 0)?'true':'false'; # '/x' ignores spaces, no match .. where only the highlighted sections above yield the expected results. All the others always return 'true'. If you can't help, then please point me in the right direction for community support. Many thanks and kind regards DT -------------- next part -------------- An HTML attachment was scrubbed... URL: From francois at busii.com Mon May 2 12:53:06 2011 From: francois at busii.com (Francois Marais) Date: Mon, 2 May 2011 21:53:06 +0200 Subject: [za-pm] Introducing Darryl Trimming ... with a regex /x modifier problem In-Reply-To: <20110502134712.575481d3@ubuntu-laptop> References: <20110502134712.575481d3@ubuntu-laptop> Message-ID: concatenation binds more closely than ternary op and logical AND &&, so the ternary is looking at the result of the concatenation (which evaluates to true, see perlsyn manpage on 'Truth vs Falsehood') and not the match , whereas in the highlighted cases the match (between parens) is evaluated first. See perlop manpage on how Perl looks at a statement. The say function is expecting a list, so to get what you expect you need something like: say (( 'h e l l o' =~ /h e l l o/x )?'true':'false') to get everything else to be evaluated and the result said Otherwise I misunderstand the question... (first day back from holiday :-) -------------- next part -------------- An HTML attachment was scrubbed... URL: From monkey_vegas at cox.net Mon May 2 14:35:47 2011 From: monkey_vegas at cox.net (James Wright) Date: Mon, 02 May 2011 14:35:47 -0700 Subject: [za-pm] Introducing Darryl Trimming ... with a regex /x modifier problem In-Reply-To: <20110502134712.575481d3@ubuntu-laptop> References: <20110502134712.575481d3@ubuntu-laptop> Message-ID: <4DBF23B3.30803@cox.net> On 05/02/11 04:47, Anne Wainwright wrote: > > > > Hi Anne > > I've just started learning perl, and found your contact details here > (http://www.pm.org/groups/522.html) while looking for community help. > It seems a bit out of date, so please forgive me if I'm knocking on > the wrong door. > B::Deparse's -p option is helpful here: > I was exploring the "/x" regexp modifier, and came upon some > unexpected results. Upon closer inspection, my problem lies with the > ternary operator. I can't see why the following results are > inconsistent .. > > say '1:'.( 'hello' =~ /h e l l o/ )?'true':'false'; # > no '/x', no match > say((('1:' . ('hello' =~ /h e l l o/)) ? 'true' : 'false')); it evaluates the string '1:' concated with the return of the regex evaluation, and '1:' is true. This can be seen by replace '1:' with '0' which is false. > > say '2:'.( 'hello' =~ /h e l l o/x )?'true':'false'; # > '/x' ignores spaces, produces '1' > say((('2:' . ('hello' =~ /h e l l o/x)) ? 'true' : 'false')); While this is 'correct' as 'hello' does match /h e l l o/x, it isn't why it returns true, it is again a concatenation of '2:' with the result of the regex match, i.e. '2:1' which is also true. > say '3:'.( 'h e l l o' =~ /h e l l o/x )?'true':'false'; # > '/x' ignores spaces, no match > say((('3:' . ('h e l l o' =~ /h e l l o/x)) ? 'true' : 'false')); The same as 1: > > say '1:'.( 'hello' =~ /h e l l o/ ).'.'; # no '/x', no match > > say '2:'.( 'hello' =~ /h e l l o/x ).'.'; # '/x' ignores spaces, > produces '1' > > say '3:'.( 'h e l l o' =~ /h e l l o/x ).'.'; # '/x' ignores spaces, > no match > > say '1:'.( 'hello' =~ /h e l l o/ ) && 'true.'; # no > '/x', no match > > say '2:'.( 'hello' =~ /h e l l o/x ) && 'true.'; # > '/x' ignores spaces, produces '1' > > say '3:'.( 'h e l l o' =~ /h e l l o/x ) && 'true.'; # > '/x' ignores spaces, no match > More of the same: > say '1:'.(( 'hello' =~ /h e l l o/ ) + 0) .'.'; # no '/x', no match > > say '2:'.(( 'hello' =~ /h e l l o/x ) + 0) .'.'; # '/x' ignores > spaces, produces '1' > > say '3:'.(( 'h e l l o' =~ /h e l l o/x ) + 0) .'.'; # '/x' ignores > spaces, no match > > say '1:'.(( 'hello' =~ /h e l l o/ ) + > 0)?'true':'false'; # no '/x', no match > > say '2:'.(( 'hello' =~ /h e l l o/x ) + > 0)?'true':'false'; # '/x' ignores spaces, produces '1' > > say '3:'.(( 'h e l l o' =~ /h e l l o/x ) + > 0)?'true':'false'; # '/x' ignores spaces, no match > > .. where only the highlighted sections above yield the expected > results. All the others always return 'true'. > > If you can't help, then please point me in the right direction for > community support. > > Many thanks and kind regards > > DT > '.' is binding closer than the ternary operator, you want something like: say '2:'.('hello' =~ /h e l l o/x ? 'true' : 'false'); to evaluate the regex match with the ternary operator, not the result of the concatenation. > > _______________________________________________ > Za-pm mailing list > Za-pm at pm.org > http://mail.pm.org/mailman/listinfo/za-pm > > posts also archived on Mail Archive > http://www.mail-archive.com/za-pm at pm.org/ -------------- next part -------------- An HTML attachment was scrubbed... URL: From anotheranne at fables.co.za Mon May 9 11:51:42 2011 From: anotheranne at fables.co.za (Anne Wainwright) Date: Mon, 9 May 2011 20:51:42 +0200 Subject: [za-pm] setting up local::lib Message-ID: <20110509205142.35088b9c@pandora> Hi, with a new machine I am aiming to get a bugfree cpan and catalyst installation this time around. (more care needed, also more knowledge available to me than previously) I did have a local installation previously but ... (lots of them). So, the Catalyst book (Diment et al. THE DEFINITIVE GUIDE TO ... ) recommends installing local::lib through cpan, thus. $ cpan cpan[1]> install local::lib nothing wrong with that, I take it, except that this is not as discussed in local::lib documentation, or on this link (which looks the same) - basically download the tarball, unzip, then the whole make procedure. http://perl.jonallen.info/writing/articles/install-perl-modules-without-root what are the implications of the two methods, or will they both result in identical installations. I await comment before committing myself at the prompt. Thanks for input. Anne From anotheranne at fables.co.za Tue May 10 13:09:02 2011 From: anotheranne at fables.co.za (Anne Wainwright) Date: Tue, 10 May 2011 22:09:02 +0200 Subject: [za-pm] setting up local::lib In-Reply-To: <20110509205142.35088b9c@pandora> References: <20110509205142.35088b9c@pandora> Message-ID: <20110510220902.66035194@pandora> In the absence of comment I followed the install instructions in the module documentation. All went well and having had a look at the .cpan directory this is good. Anne > Note: Beware! Default reply-to is to the list. > > > Hi, > > with a new machine I am aiming to get a bugfree cpan and catalyst > installation this time around. (more care needed, also more knowledge > available to me than previously) I did have a local installation > previously but ... (lots of them). > > So, the Catalyst book (Diment et al. THE DEFINITIVE GUIDE TO ... ) > recommends installing local::lib through cpan, thus. > > $ cpan > cpan[1]> install local::lib > > nothing wrong with that, I take it, except that this is not as > discussed in local::lib documentation, or on this link (which looks > the same) - basically download the tarball, unzip, then the whole > make procedure. > > http://perl.jonallen.info/writing/articles/install-perl-modules-without-root > > what are the implications of the two methods, or will they both result > in identical installations. > > I await comment before committing myself at the prompt. Thanks for > input. > > Anne > _______________________________________________ > Za-pm mailing list > Za-pm at pm.org > http://mail.pm.org/mailman/listinfo/za-pm > > posts also archived on Mail Archive > http://www.mail-archive.com/za-pm at pm.org/ From anotheranne at fables.co.za Sun May 22 12:04:19 2011 From: anotheranne at fables.co.za (Anne Wainwright) Date: Sun, 22 May 2011 21:04:19 +0200 Subject: [za-pm] make test had returned bad status, won't install without force Message-ID: <20110522210419.72b9ddc1@pandora> Hi, all, I was running $ cpan Catalyst::Helper::AuthDBIC when the 'Subject' error was returned. What should be my generic response to something like this? Should I try to force an installation or will I dig myself in deeper doing this? That particular module scores a huge number of install 'fails' in the module reports on cpan. (This is in the Catalyst book. first time around I had no issues but with a new installation obviously I do. the errata (which had nothing on this then) is now nowhere to be found) Thanks for any comments or suggestions. regards Anne From anotheranne at fables.co.za Mon May 23 12:08:02 2011 From: anotheranne at fables.co.za (Anne Wainwright) Date: Mon, 23 May 2011 21:08:02 +0200 Subject: [za-pm] make test had returned bad status, won't install without force In-Reply-To: <20110522210419.72b9ddc1@pandora> References: <20110522210419.72b9ddc1@pandora> Message-ID: <20110523210802.5f74685b@pandora> Hi, I chose the 'force' option, it installed, it works. anne On Sun, 22 May 2011 21:04:19 +0200 Anne Wainwright wrote: > Note: Beware! Default reply-to is to the list. > > > Hi, all, > > I was running > > $ cpan Catalyst::Helper::AuthDBIC > > when the 'Subject' error was returned. > > What should be my generic response to something like this? Should I > try to force an installation or will I dig myself in deeper doing > this? > > That particular module scores a huge number of install 'fails' in the > module reports on cpan. > > (This is in the Catalyst book. first time around I had no issues but > with a new installation obviously I do. the errata (which had nothing > on this then) is now nowhere to be found) > > Thanks for any comments or suggestions. > > regards > Anne > _______________________________________________ > Za-pm mailing list > Za-pm at pm.org > http://mail.pm.org/mailman/listinfo/za-pm > > posts also archived on Mail Archive > http://www.mail-archive.com/za-pm at pm.org/ From anotheranne at fables.co.za Sun Jun 5 04:41:52 2011 From: anotheranne at fables.co.za (Anne Wainwright) Date: Sun, 5 Jun 2011 13:41:52 +0200 Subject: [za-pm] module to output programme skeleton Message-ID: <20110605134152.02b449c9@pandora> Hi, are there any informational cpan modules that will print recursively the content of modules in a structure. ie output directory package name use statements subroutine names I was looking for something that would give a structure overview, as simple as above, or more detailed not refused. Something that could be used at the command line like perltidy or perlcritic. have been looking at cpan but it is like looking for a needle in a haystack! any ideas? thanks Anne From anotheranne at fables.co.za Sun Jun 5 04:45:51 2011 From: anotheranne at fables.co.za (Anne Wainwright) Date: Sun, 5 Jun 2011 13:45:51 +0200 Subject: [za-pm] file extension match to syntax highlighting in vim Message-ID: <20110605134551.01d4d9d3@pandora> Hi, when I have run perltidy I like to compare to the original file, but the extension .pl.tdy does not pick up. I have been looking this morning but cannot find what I need - somewhere to add in '.tdy' so that it gets the perl syntax highlighting. can someone give me a pointer please? Anne From spike at mweb.co.za Mon Jun 6 00:11:34 2011 From: spike at mweb.co.za (Spike) Date: Mon, 06 Jun 2011 09:11:34 +0200 Subject: [za-pm] file extension match to syntax highlighting in vim In-Reply-To: <20110605134551.01d4d9d3@pandora> References: <20110605134551.01d4d9d3@pandora> Message-ID: <4DEC7DA6.7070908@mweb.co.za> Hi Anne I have an alias 'plt' which just runs perltidy -b. This copies my original.pl to original.pl.bak and gives original.pl as the tidy one. I've modified my perltidy_rc to do what I want so providing the script passes a 'perl -cw' it is always what I want. vi (or rather vim) displays the .bak just as it displays the .pl/ Maybe it has an 'understanding' .bak built in? I can post my vimrc if you like. On a similar note I once chased the lack of syntax highlighting and odd vi behavior for an hour only to realize that when logged in as myself vi was aliased to vim but as root it launched the original vi with no bells and whistles. If anyone is not using perltidy I can strongly recommend it. It installs reliably from cpan with'cpan -i Perl::Tidy' on the CL. On 2011-06-05 13:45, Anne Wainwright wrote: > Note: Beware! Default reply-to is to the list. > > > Hi, > > when I have run perltidy I like to compare to the original file, but > the extension .pl.tdy does not pick up. > > I have been looking this morning but cannot find what I need - > somewhere to add in '.tdy' so that it gets the perl syntax highlighting. > > can someone give me a pointer please? > > Anne > _______________________________________________ > Za-pm mailing list > Za-pm at pm.org > http://mail.pm.org/mailman/listinfo/za-pm > > posts also archived on Mail Archive > http://www.mail-archive.com/za-pm at pm.org/ From nick at cleaton.net Mon Jun 6 02:26:57 2011 From: nick at cleaton.net (Nick Cleaton) Date: Mon, 6 Jun 2011 10:26:57 +0100 Subject: [za-pm] file extension match to syntax highlighting in vim In-Reply-To: <20110605134551.01d4d9d3@pandora> References: <20110605134551.01d4d9d3@pandora> Message-ID: On Sun, Jun 5, 2011 at 12:45 PM, Anne Wainwright wrote: > > when I have run perltidy I like to compare to the original file, but > the extension .pl.tdy does not pick up. > > I have been looking this morning but cannot find what I need - > somewhere to add in '.tdy' so that it gets the perl syntax highlighting. > > can someone give me a pointer please? In your .vimrc: autocmd BufRead *.pl.tdy setlocal filetype=perl From anotheranne at fables.co.za Mon Jun 6 12:29:05 2011 From: anotheranne at fables.co.za (Anne Wainwright) Date: Mon, 6 Jun 2011 21:29:05 +0200 Subject: [za-pm] file extension match to syntax highlighting in vim In-Reply-To: References: <20110605134551.01d4d9d3@pandora> Message-ID: <20110606212905.19e4639f@pandora> Hello, Nick, that works! bestest Anne On Mon, 6 Jun 2011 10:26:57 +0100 Nick Cleaton wrote: > autocmd BufRead *.pl.tdy setlocal filetype=perl