Re: [za-pm] perl highlight mode in gedit & Vim
Note: Beware! Default reply-to is to the list. On Sep 29, 2010, at 3:22 PM, Anne Wainwright wrote: end of ever so much more perl code 1; __END__ =head1 HEADING final pod comments more final pod comments The __END__ is not needed in this example because there is no code following the __END__ which you might want to hide from the Perl Parser. When the parser reaches '=head1', it knows it has reached POD and deals with it accordingly. The simplest explanation of __END__ I could find is here: http://www.platypiventures.com/perl/present/MakeModule/013.html Depending on circumstances, the '1;' may not be needed, either. The '1;' is merely the prototypical case of ending a file with a statement that Perl evaluates as true. You could just as easily follow Mark-Jason Dominus' practice of ending a module with: 'cogito ergo sum'; You need to end the file with a statement that evaluates to true if and only if the file is going to be imported by 'use', 'require' or 'do' into some other Perl program. A '.pm' module you will download from CPAN typically ends with '1;' for this reason. But a standalone Perl script doesn't need it. Whether your file needs to end in a true statement or not, you can write POD following the final code statement. Thank you very much. Jim Keenan ___ Za-pm mailing list Za-pm@pm.org http://mail.pm.org/mailman/listinfo/za-pm posts also archived on Mail Archive http://www.mail-archive.com/za-pm@pm.org/
Re: [za-pm] perl highlight mode in gedit & Vim
Note: Beware! Default reply-to is to the list. Hello, Edoardo, see below On Wed, 29 Sep 2010 21:50:45 +0200 Edoardo Sabadelli wrote: > Note: Beware! Default reply-to is to the list. > > > On Wed, Sep 29, 2010 at 9:33 PM, Anne Wainwright > wrote: > > Note: Beware! Default reply-to is to the list. > > > > > > Hello, > > > > Second take. > > > > Actually vim is better behaved than I described, its perl > > highlighting puts all the pod elements and comments in one common > > colour, which behaviour stays the same irrespective of the location > > of the __END__ token, it is in gvim that the elements (like head1) > > are in a distinctive colour that evaporates if the __END__ token > > precedes them. > > > > So I think that gedit just has its little ways. The loss of > > highlighting made me think I had something wrong, that was really > > the issue that threw me. > > > > Anne > > Hi Anne, I use Vim for all my coding and I noticed some highlighting > problems only sometimes when scrolling, but always when in the code > there are some particular conditions, such as escaped quotes in > strings or interpolated strings that span on several lines. > Usually when scrolling further those issues disappear. > > Besides that, I took the habit of using F8 for saving when I work on > Perl files. I use this simple mapping in Vim (~/.vimrc file): > > map :w:! perl -c % well, this evening I had been trying the perl -c switch on some files for the first time, very good, so some synchronicity there! Since I seem to spend serious time trying to catch syntax errors (aka spelling mistakes) that will make for some time saving for me. I deleted a ';' in a regularly used file, and ran perl with the -c switch and I see it pops up syntax help, the same as when you run the file with an error. Could be useful, hey! I'll experiment with your mapping as given above. thanks Anne > > which as you might notice, saves the file (:w), then runs the perl > syntax checker (:! perl -c %). > The `' is the same as pressing Enter. > `:!' gives you access to the shell in which Vim is running, and `%' > represents the current file. > > So, whenever I press F8, the file is saved and the Perl syntax is > checked automatically, showing me any syntax error I might have in my > file. > > Try it, is very useful :) > ___ Za-pm mailing list Za-pm@pm.org http://mail.pm.org/mailman/listinfo/za-pm posts also archived on Mail Archive http://www.mail-archive.com/za-pm@pm.org/
Re: [za-pm] perl highlight mode in gedit & Vim
Note: Beware! Default reply-to is to the list. On Wed, Sep 29, 2010 at 9:33 PM, Anne Wainwright wrote: > Note: Beware! Default reply-to is to the list. > > > Hello, > > Second take. > > Actually vim is better behaved than I described, its perl highlighting > puts all the pod elements and comments in one common colour, which > behaviour stays the same irrespective of the location of the __END__ > token, it is in gvim that the elements (like head1) are in a > distinctive colour that evaporates if the __END__ token precedes them. > > So I think that gedit just has its little ways. The loss of > highlighting made me think I had something wrong, that was really the > issue that threw me. > > Anne Hi Anne, I use Vim for all my coding and I noticed some highlighting problems only sometimes when scrolling, but always when in the code there are some particular conditions, such as escaped quotes in strings or interpolated strings that span on several lines. Usually when scrolling further those issues disappear. Besides that, I took the habit of using F8 for saving when I work on Perl files. I use this simple mapping in Vim (~/.vimrc file): map :w:! perl -c % which as you might notice, saves the file (:w), then runs the perl syntax checker (:! perl -c %). The `' is the same as pressing Enter. `:!' gives you access to the shell in which Vim is running, and `%' represents the current file. So, whenever I press F8, the file is saved and the Perl syntax is checked automatically, showing me any syntax error I might have in my file. Try it, is very useful :) -- Edoardo ___ Za-pm mailing list Za-pm@pm.org http://mail.pm.org/mailman/listinfo/za-pm posts also archived on Mail Archive http://www.mail-archive.com/za-pm@pm.org/
Re: [za-pm] perl highlight mode in gedit & Vim
Note: Beware! Default reply-to is to the list. Hello, Second take. Actually vim is better behaved than I described, its perl highlighting puts all the pod elements and comments in one common colour, which behaviour stays the same irrespective of the location of the __END__ token, it is in gvim that the elements (like head1) are in a distinctive colour that evaporates if the __END__ token precedes them. So I think that gedit just has its little ways. The loss of highlighting made me think I had something wrong, that was really the issue that threw me. Anne On Wed, 29 Sep 2010 21:22:44 +0200 Anne Wainwright wrote: > Note: Beware! Default reply-to is to the list. > > > Hi, > > After studying harder and getting my brain around complex data > structures I am off charging (well, relatively so) thru the new > Catalyst book, putting in the examples and getting them to work and > understanding how they work. Now: > > Please tell me that i have this right > perl file outline: > > appropriate #! start stuff > > perl code > .. > even more perl code > .. > end of perl code > > =head1 HEADING > > pod comments > more pod comments > > =cut > > ever so much more perl code > .. > even more ever so much more perl code > .. > end of ever so much more perl code > 1; > __END__ > > =head1 HEADING > > final pod comments > more final pod comments > > =cut > > The __END__ token signifies to the parser that there is definitely no > more perl code past that point only, in this case, pod stuff > > The perl syntax highlighting in gedit stops at the __END__ token, that > is to say that past that point =head1 & =cut do not have the benefit > of the editor syntax highlighting. > > Does this happen with all other editors? (I know it does in gVim as > well). I just wondered where the highlighting went to, it usually > gives in when you have something wrong, not when you have it right > for once. > > It's sort of logical, and sort of not. Either the editor is going to > supply highlighting or it isn't. Only if I put the __END__ token at > the _very_ end of the file, past the final =cut, is the highlighting > of the pod elements restored, but this sort of negates the purpose of > the __END__ token (presumably to mark the end of code to be parsed and > thus save time normally spent parsing non-code pod stuff. > > Does any one take issue with the putting of the __END__ token right > after the 1; and forget about the highlighting of the final batch of > pod stuff? Are some other editors better behaved? > > ps. just doing small stuff I stick with gedit, but am investigating > vim just in case. > > Thanks > Anne > ___ > Za-pm mailing list > Za-pm@pm.org > http://mail.pm.org/mailman/listinfo/za-pm > > posts also archived on Mail Archive > http://www.mail-archive.com/za-pm@pm.org/ ___ Za-pm mailing list Za-pm@pm.org http://mail.pm.org/mailman/listinfo/za-pm posts also archived on Mail Archive http://www.mail-archive.com/za-pm@pm.org/