From legrady at gmail.com Tue May 2 17:00:15 2017 From: legrady at gmail.com (Tom Legrady) Date: Tue, 2 May 2017 20:00:15 -0400 Subject: [tpm] Filehandle $fh opened only for output at .... Message-ID: <751901e7-56da-25b1-27f5-00b6217db97a@gmail.com> I've got an old, bad program running under Perl 5.6.1 which opens a continuously growing file, and writes the contents to a socket, to copy it to another server. It's filling the log file with lines like "Filehandle $fh opened only for output at filename, line 71, <$fh> line N. But $fh is opened for input, not output, and the contents are being copied to the remote site. I wonder if it's because the script is trying to read after arriving to the current eof. The code looks like forever () { my $sent; while ( my $bug = <$fh> ) { #send buf to socket; increment $sent } # send a heartbeat to socket if not $sent } Any advice? I AM working on migrating to a newer version of Perl, but the old version is generating a lot of junk. Tom From zoffix at zoffix.com Tue May 2 17:43:20 2017 From: zoffix at zoffix.com (zoffix at zoffix.com) Date: Tue, 02 May 2017 20:43:20 -0400 Subject: [tpm] Filehandle $fh opened only for output at .... In-Reply-To: <751901e7-56da-25b1-27f5-00b6217db97a@gmail.com> Message-ID: <20170502204320.Horde.KIoT-nzpccgPumafIcaXxJu@echo.gendns.com> Quoting Tom Legrady : > I've got an old, bad program running under Perl 5.6.1 Wow! I didn't even know they made Perl that old! :) > The code looks like > while ( my $bug = <$fh> ) { As I recall the idiom is `while (defined(my $foo = <$fh>))` Are you *sure sure* it's actually opened for output? What's your open line? It should have `<` for mode, not `>` Cheers, ZZ > > > Tom > _______________________________________________ > toronto-pm mailing list > toronto-pm at pm.org > http://mail.pm.org/mailman/listinfo/toronto-pm From legrady at gmail.com Tue May 2 19:28:23 2017 From: legrady at gmail.com (Tom Legrady) Date: Tue, 2 May 2017 22:28:23 -0400 Subject: [tpm] Filehandle $fh opened only for output at .... In-Reply-To: <20170502204320.Horde.KIoT-nzpccgPumafIcaXxJu@echo.gendns.com> References: <20170502204320.Horde.KIoT-nzpccgPumafIcaXxJu@echo.gendns.com> Message-ID: <8c0c942f-9302-4c7e-eba7-3dbf630cc754@gmail.com> I have ',', I read hundreds of MB of data from the one file, dozens of MB from the other. You're right, It SHOULD be 'defined', so that reading a zero or an empty string doesn't break out of the loop. But I don't THINK that would cause this error. Some of the files contain "version control comments" dated to '92, '93 ... so they may have started as Perl4 ... stylistically it's believable of some of the code. But I am here to baptize and purify and lead the code to salvation. Tom On 2017-05-02 08:43 PM, zoffix at zoffix.com wrote: > > Quoting Tom Legrady : > >> I've got an old, bad program running under Perl 5.6.1 > > Wow! I didn't even know they made Perl that old! :) > >> The code looks like >> while ( my $bug = <$fh> ) { > > As I recall the idiom is `while (defined(my $foo = <$fh>))` > > Are you *sure sure* it's actually opened for output? What's your open > line? It should have `<` for mode, not `>` > > > Cheers, > ZZ > > >> >> >> Tom >> _______________________________________________ >> toronto-pm mailing list >> toronto-pm at pm.org >> http://mail.pm.org/mailman/listinfo/toronto-pm > > > From shlomif at shlomifish.org Wed May 3 11:53:23 2017 From: shlomif at shlomifish.org (Shlomi Fish) Date: Wed, 3 May 2017 21:53:23 +0300 Subject: [tpm] Filehandle $fh opened only for output at .... In-Reply-To: <20170502204320.Horde.KIoT-nzpccgPumafIcaXxJu@echo.gendns.com> References: <751901e7-56da-25b1-27f5-00b6217db97a@gmail.com> <20170502204320.Horde.KIoT-nzpccgPumafIcaXxJu@echo.gendns.com> Message-ID: <20170503215323.137a1421@telaviv1.shlomifish.org> Hi Zoffix and Tom! On Tue, 02 May 2017 20:43:20 -0400 zoffix at zoffix.com wrote: > Quoting Tom Legrady : > > > I've got an old, bad program running under Perl 5.6.1 > > Wow! I didn't even know they made Perl that old! :) > > > The code looks like > > while ( my $bug = <$fh> ) { > > As I recall the idiom is `while (defined(my $foo = <$fh>))` > From what I recall the defined is added implicitly in simple = <...> loops like that (but may not be with more complex conditions). See: ? shlomif at lap:~$ cat myprog.pl #!/usr/bin/perl use strict; use warnings; open my $in, '<', 'file.txt' or die "Blah!"; while (my $l = <$in>) { print "Got <$l>\n"; } close $in; shlomif at lap:~$ cat file.txt hello 0 shlomif at lap:~$ perl myprog.pl Got Got <0 > Got < > Got < > Got < > shlomif at lap:~$ shlomif at lap:~$ echo -n $'hello\n0\n\n\n0' > file.txt shlomif at lap:~$ perl myprog.pl Got Got <0 > Got < > Got < > Got <0> shlomif at lap:~$ ? Adding define there won't hurt though. Regards, Shlomi Fish > Are you *sure sure* it's actually opened for output? What's your open > line? It should have `<` for mode, not `>` > > > Cheers, > ZZ > > > > > > > > Tom > > _______________________________________________ > > toronto-pm mailing list > > toronto-pm at pm.org > > http://mail.pm.org/mailman/listinfo/toronto-pm > _______________________________________________ > toronto-pm mailing list > toronto-pm at pm.org > http://mail.pm.org/mailman/listinfo/toronto-pm From arocker at Vex.Net Wed May 3 13:33:27 2017 From: arocker at Vex.Net (arocker at Vex.Net) Date: Wed, 3 May 2017 16:33:27 -0400 Subject: [tpm] Filehandle $fh opened only for output at .... In-Reply-To: <20170503215323.137a1421@telaviv1.shlomifish.org> References: <751901e7-56da-25b1-27f5-00b6217db97a@gmail.com> <20170502204320.Horde.KIoT-nzpccgPumafIcaXxJu@echo.gendns.com> <20170503215323.137a1421@telaviv1.shlomifish.org> Message-ID: >> > The code looks like >> > while ( my $bug = <$fh> ) { >> >> As I recall the idiom is `while (defined(my $foo = <$fh>))` >> > > From what I recall the defined is added implicitly in simple = <...> loops > like that (but may not be with more complex conditions). See: > Isn't the "defined" there to deal with the case where the expression evaluates to a false value? From zoffix at zoffix.com Wed May 3 14:21:29 2017 From: zoffix at zoffix.com (zoffix at zoffix.com) Date: Wed, 03 May 2017 17:21:29 -0400 Subject: [tpm] Filehandle $fh opened only for output at .... In-Reply-To: References: <751901e7-56da-25b1-27f5-00b6217db97a@gmail.com> <20170502204320.Horde.KIoT-nzpccgPumafIcaXxJu@echo.gendns.com> <20170503215323.137a1421@telaviv1.shlomifish.org> Message-ID: <20170503172129.Horde.Pwr-twxDgIi6u4neL84yKoT@echo.gendns.com> Quoting Shlomi Fish : > Hi Zoffix and Tom! \o Didn't expect you to follow Toronto's list :) >>> As I recall the idiom is `while (defined(my $foo = <$fh>))` I think I sidetracked the discussion with that comment :) I highly doubt the `defined` is the cause of the issue or that perl would be lying about the handle not being opened for writing. Likely the handle is re-opened by some adjacent code or file handle's variable accidentally reused in another open, like passed via a sub, for example. $ perl -we 'open my $fh, "<", "foo"; open $fh, ">", "foo"; <$fh>' Filehandle $fh opened only for output at -e line 1. $ perl -we 'sub foo { open $_[0], ">", "foo"; }; open my $fh, "<", "foo"; foo $fh; <$fh>' Filehandle $fh opened only for output at -e line 1. Perhaps the OP can provide a larger piece of code; something that traces the life of $fh. From legrady at gmail.com Wed May 3 16:40:30 2017 From: legrady at gmail.com (Tom Legrady) Date: Wed, 3 May 2017 19:40:30 -0400 Subject: [tpm] Filehandle $fh opened only for output at .... In-Reply-To: <20170503172129.Horde.Pwr-twxDgIi6u4neL84yKoT@echo.gendns.com> References: <751901e7-56da-25b1-27f5-00b6217db97a@gmail.com> <20170502204320.Horde.KIoT-nzpccgPumafIcaXxJu@echo.gendns.com> <20170503215323.137a1421@telaviv1.shlomifish.org> <20170503172129.Horde.Pwr-twxDgIi6u4neL84yKoT@echo.gendns.com> Message-ID: <62e69a9e-de26-f8f6-2235-f325b8aa6d37@gmail.com> Unfortunately at the moment I am unable to log onto the machine the file is copied to, so I cannot show that it grows to hugeity. Later this week, perhaps. Tom On 2017-05-03 05:21 PM, zoffix at zoffix.com wrote: > > Quoting Shlomi Fish : >> Hi Zoffix and Tom! > > \o Didn't expect you to follow Toronto's list :) > >>>> As I recall the idiom is `while (defined(my $foo = <$fh>))` > > I think I sidetracked the discussion with that comment :) > > I highly doubt the `defined` is the cause of the issue or that perl > would be lying about the handle not being opened for writing. Likely > the handle is re-opened by some adjacent code or file handle's > variable accidentally reused in another open, like passed via a sub, > for example. > > $ perl -we 'open my $fh, "<", "foo"; open $fh, ">", "foo"; <$fh>' > Filehandle $fh opened only for output at -e line 1. > > $ perl -we 'sub foo { open $_[0], ">", "foo"; }; open my $fh, "<", > "foo"; foo $fh; <$fh>' > Filehandle $fh opened only for output at -e line 1. > > Perhaps the OP can provide a larger piece of code; something that > traces the life of $fh. > _______________________________________________ > toronto-pm mailing list > toronto-pm at pm.org > http://mail.pm.org/mailman/listinfo/toronto-pm From htessmann at control-tec.com Thu May 4 17:24:42 2017 From: htessmann at control-tec.com (Harold Tessmann) Date: Thu, 4 May 2017 20:24:42 -0400 Subject: [tpm] Seeking advice on using Perl in a professional way Message-ID: Hi from Michigan! Apologies if that?s a little far away for the Toronto list, but the local pm.org mailing lists seems a little dead. I'm looking to productionize some Perl scripts, and as such, I want to adopt more structure than I use in disposable scripts. These scripts would be used within the bounds of my employer, not released to the general public (with maybe one or two exceptions). I know that TIMTOWTDI, but I like the ?sometimes consistency is not a bad thing either? extension when it comes to common problems such as command-line option parsing, and the perldocs don?t go in depth on what people use in the real world. I?m looking for advice on topics including, but not limited to: ? Modern Perl: I like it in general, and I can install it on my team?s machines. Are there reasons I shouldn?t use it? ? Does anybody have a suggestion for a good blank script template? For instance, I know I want "use Modern::Perl 'version';" or "use warnings/strict;", etc., but there?s probably other things I would want in a basic script. I?ve handled this in a sort of ad-hoc manner, growing new scripts based on what I learned from the old, but I?d like to build a good template once and be done with it. I?d also like the template to include documentation, and that raises more questions. Is there a reason to put my pod block near the top vs. the bottom? Getopt::Tiny seems nice, including a feature to automagically build a usage block?should I use that or is there a reason to avoid it? Or is there a better option parser? ? Do you run Perl::Critic on your code? I know I?ll disable some of the rules, but is it more hassle overall than it?s worth? Similarly, PerlTidy: it seems useful for generating HTML versions of documentation, but I write code in a very precise way, such it would take more time to configure it than I would save in reformatting. ? Thus far I haven?t built anything complicated enough to warrant figuring out an object library; I can get by with basic hash-based structures. I?ve read a bit about Moose and Dancer: how do they compare? And what else is widely-used that I should consider? Any advice is greatly appreciated. Thanks, Harold -------------- next part -------------- An HTML attachment was scrubbed... URL: From talexb at gmail.com Thu May 4 17:41:43 2017 From: talexb at gmail.com (Alex Beamish) Date: Thu, 4 May 2017 20:41:43 -0400 Subject: [tpm] Seeking advice on using Perl in a professional way In-Reply-To: References: Message-ID: Hi Harold, Always glad to chime in on this kind of stuff. For production scripts, apart from the code being as solid as possible (more later), the most important thing is to add in consistent logging. Log when the script starts, when it finishes, and whenever anything significant is found. And check those logs regularly for anything odd. My current bunch of scripts are moving data around, so I've made undefined variables fatal, so as to catch the unwanted undef -> '' or 0 transformation. By all means use PerlTidy on your scripts during development -- it allows your eyes to easily absorb lots of detail, and doesn't affect performance at all. Using strict and warnings is very important as well. The code should be clean, clean, clean. Perlcritic is also good, but I don't agree with all of Damian's recommendations -- ignore the warnings you think are unnecessary. Where to put POD is usually open to debate, but I prefer it all at the bottom, rather than interspersed with code, because I like to see as much code at once as possible. Finally, this may be heresy in this group, but I'm not a fan of making everything into an object. I can build a HoH or AoH to do just about anything I need, and in my current assignment I've been using AoH's with each element containing a code ref to get stuff done. Very neat, and very handy. Cheers, Alex On Thu, May 4, 2017 at 8:24 PM, Harold Tessmann wrote: > Hi from Michigan! Apologies if that?s a little far away for the Toronto > list, but the local pm.org mailing lists seems a little dead. > > I'm looking to productionize some Perl scripts, and as such, I want to > adopt more structure than I use in disposable scripts. These scripts would > be used within the bounds of my employer, not released to the general > public (with maybe one or two exceptions). I know that TIMTOWTDI, but I > like the ?sometimes consistency is not a bad thing either? extension when > it comes to common problems such as command-line option parsing, and the > perldocs don?t go in depth on what people use in the real world. I?m > looking for advice on topics including, but not limited to: > > ? Modern Perl: I like it in general, and I can install it on my team?s > machines. Are there reasons I shouldn?t use it? > > ? Does anybody have a suggestion for a good blank script template? For > instance, I know I want "use Modern::Perl 'version';" or "use > warnings/strict;", etc., but there?s probably other things I would want in > a basic script. I?ve handled this in a sort of ad-hoc manner, growing new > scripts based on what I learned from the old, but I?d like to build a good > template once and be done with it. I?d also like the template to include > documentation, and that raises more questions. Is there a reason to put my > pod block near the top vs. the bottom? Getopt::Tiny seems nice, including a > feature to automagically build a usage block?should I use that or is there > a reason to avoid it? Or is there a better option parser? > > ? Do you run Perl::Critic on your code? I know I?ll disable some of the > rules, but is it more hassle overall than it?s worth? Similarly, PerlTidy: > it seems useful for generating HTML versions of documentation, but I write > code in a very precise way, such it would take more time to configure it > than I would save in reformatting. > > ? Thus far I haven?t built anything complicated enough to warrant figuring > out an object library; I can get by with basic hash-based structures. I?ve > read a bit about Moose and Dancer: how do they compare? And what else is > widely-used that I should consider? > > Any advice is greatly appreciated. > > Thanks, > Harold > > _______________________________________________ > toronto-pm mailing list > toronto-pm at pm.org > http://mail.pm.org/mailman/listinfo/toronto-pm > > -- Alex Beamish Software Developer / https://ca.linkedin.com/in/alex-beamish-5111ba3 Baritone, Board Member, Toronto Northern Lights, 2013 Champions / www.northernlightschorus.com Certified Contest Administrator, Barbershop Harmony Society / www.barbershop.org -------------- next part -------------- An HTML attachment was scrubbed... URL: From ceeshek at gmail.com Thu May 4 19:00:09 2017 From: ceeshek at gmail.com (Cees Hek) Date: Thu, 4 May 2017 22:00:09 -0400 Subject: [tpm] Seeking advice on using Perl in a professional way In-Reply-To: References: Message-ID: Following on with Alex's suggestions, perl has wonderful tools for writing tests for your code, but command line scripts can be notoriously difficult to test. If you treat everything as a class or object it can give your code better structure and separation, but it can also greatly simplify your tests. Have a look at MooseX::App. It gives you a nice framework for handling command line options, and treats your command line app as an object. It will also automatically build your --help output for you. Using Moose will also allow you to write much cleaner and more expressive code. Cheers, Cees On Thu, May 4, 2017 at 8:41 PM, Alex Beamish wrote: > Hi Harold, > > Always glad to chime in on this kind of stuff. > > For production scripts, apart from the code being as solid as possible > (more later), the most important thing is to add in consistent logging. Log > when the script starts, when it finishes, and whenever anything significant > is found. And check those logs regularly for anything odd. > > My current bunch of scripts are moving data around, so I've made undefined > variables fatal, so as to catch the unwanted undef -> '' or 0 > transformation. > > By all means use PerlTidy on your scripts during development -- it allows > your eyes to easily absorb lots of detail, and doesn't affect performance > at all. Using strict and warnings is very important as well. The code > should be clean, clean, clean. Perlcritic is also good, but I don't agree > with all of Damian's recommendations -- ignore the warnings you think are > unnecessary. > > Where to put POD is usually open to debate, but I prefer it all at the > bottom, rather than interspersed with code, because I like to see as much > code at once as possible. > > Finally, this may be heresy in this group, but I'm not a fan of making > everything into an object. I can build a HoH or AoH to do just about > anything I need, and in my current assignment I've been using AoH's with > each element containing a code ref to get stuff done. Very neat, and very > handy. > > Cheers, > > Alex > > > On Thu, May 4, 2017 at 8:24 PM, Harold Tessmann > wrote: > >> Hi from Michigan! Apologies if that?s a little far away for the Toronto >> list, but the local pm.org mailing lists seems a little dead. >> >> I'm looking to productionize some Perl scripts, and as such, I want to >> adopt more structure than I use in disposable scripts. These scripts would >> be used within the bounds of my employer, not released to the general >> public (with maybe one or two exceptions). I know that TIMTOWTDI, but I >> like the ?sometimes consistency is not a bad thing either? extension when >> it comes to common problems such as command-line option parsing, and the >> perldocs don?t go in depth on what people use in the real world. I?m >> looking for advice on topics including, but not limited to: >> >> ? Modern Perl: I like it in general, and I can install it on my team?s >> machines. Are there reasons I shouldn?t use it? >> >> ? Does anybody have a suggestion for a good blank script template? For >> instance, I know I want "use Modern::Perl 'version';" or "use >> warnings/strict;", etc., but there?s probably other things I would want in >> a basic script. I?ve handled this in a sort of ad-hoc manner, growing new >> scripts based on what I learned from the old, but I?d like to build a good >> template once and be done with it. I?d also like the template to include >> documentation, and that raises more questions. Is there a reason to put my >> pod block near the top vs. the bottom? Getopt::Tiny seems nice, including a >> feature to automagically build a usage block?should I use that or is there >> a reason to avoid it? Or is there a better option parser? >> >> ? Do you run Perl::Critic on your code? I know I?ll disable some of the >> rules, but is it more hassle overall than it?s worth? Similarly, PerlTidy: >> it seems useful for generating HTML versions of documentation, but I write >> code in a very precise way, such it would take more time to configure it >> than I would save in reformatting. >> >> ? Thus far I haven?t built anything complicated enough to warrant >> figuring out an object library; I can get by with basic hash-based >> structures. I?ve read a bit about Moose and Dancer: how do they compare? >> And what else is widely-used that I should consider? >> >> Any advice is greatly appreciated. >> >> Thanks, >> Harold >> >> _______________________________________________ >> toronto-pm mailing list >> toronto-pm at pm.org >> http://mail.pm.org/mailman/listinfo/toronto-pm >> >> > > > -- > Alex Beamish > > Software Developer / https://ca.linkedin.com/in/alex-beamish-5111ba3 > Baritone, Board Member, Toronto Northern Lights, 2013 Champions / > www.northernlightschorus.com > Certified Contest Administrator, Barbershop Harmony Society / > www.barbershop.org > > > _______________________________________________ > toronto-pm mailing list > toronto-pm at pm.org > http://mail.pm.org/mailman/listinfo/toronto-pm > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From zoffix at zoffix.com Thu May 4 19:06:27 2017 From: zoffix at zoffix.com (zoffix at zoffix.com) Date: Thu, 04 May 2017 22:06:27 -0400 Subject: [tpm] Seeking advice on using Perl in a professional way In-Reply-To: Message-ID: <20170504220627.Horde.zByLQKTrlz615GeqeWrgBOp@echo.gendns.com> Quoting Harold Tessmann : > Hi from Michigan! Apologies if that?s a little far away for the Toronto > list, but the local pm.org mailing lists seems a little dead. Welcome! A little dead in Michigan? Must be something in the water... > I'm looking to productionize some Perl scripts, and as such, I want to > adopt more structure than I use in disposable scripts. These scripts would > be used within the bounds of my employer, not released to the general > public (with maybe one or two exceptions). I know that TIMTOWTDI, but I > like the ?sometimes consistency is not a bad thing either? extension when > it comes to common problems such as command-line option parsing, and the > perldocs don?t go in depth on what people use in the real world. I?m > looking for advice on topics including, but not limited to: I don't know if your employer mandates which Perl to use, but I found Perl 6 to be much more apt for command-line-parsing scripts and one- or few-liners than Perl 5. It has much more concise syntax and comes with command line parsing built in: http://linuxtot.com/parsing-command-line-arguments-in-perl-6/ > ? Modern Perl: I like it in general, and I can install it on my team?s > machines. Are there reasons I shouldn?t use it? It doesn't really look like some must-have module to me. Feels more like something opionated that's well-known simply because chromatic put it into his book. I don't use it and you can make your own, more useful bundle of stuff with https://metacpan.org/pod/Import::Into > > ? Does anybody have a suggestion for a good blank script template? For > instance, I know I want "use Modern::Perl 'version';" or "use > warnings/strict;", etc., but there?s probably other things I would want in > a basic script. I?ve handled this in a sort of ad-hoc manner, growing new > scripts based on what I learned from the old, but I?d like to build a good > template once and be done with it. I?d also like the template to include > documentation, and that raises more questions. Is there a reason to put my > pod block near the top vs. the bottom? Getopt::Tiny seems nice, including a > feature to automagically build a usage block?should I use that or is there > a reason to avoid it? Or is there a better option parser? As mentioned, Perl 6! :) There's no boiler plate and sub MAIN does the arg parsing and usage generation, so the entire template is just `sub MAIN () {}` But if Perl 5 is your thing, reused templates sound like a terrible idea. One day you'll end up editing something in all of your scripts just because part of your template needs a change. Use something like Import::Into to collect all the modules you use into a single module and add some helper subs into it. Then use just that one module in all your scripts instead of a template, so if you ever need to make a changed, you'd only need to change that one module once. And as Cees mentioned, it's much easier to test the stuff as well. P.S.: the improved version of `use strict/warnings` is `use strictures 2;`. It fatalizes some of the warnings that usually indicate an issue in your script: https://metacpan.org/pod/strictures > Is there a reason to put my > pod block near the top vs. the bottom? Always put at the bottom. There's nothing worse than inter-mixed Pod and code when you end up reading a script without a syntax highlighter. It's just impossible to keep track of which chunk of code is code-code and which is just a pod code example. > ? Do you run Perl::Critic on your code? I know I?ll disable some of the > rules, but is it more hassle overall than it?s worth? Similarly, PerlTidy: > it seems useful for generating HTML versions of documentation, but I write > code in a very precise way, such it would take more time to configure it > than I would save in reformatting. I don't, but I think I'm an exception. I prefer to manually make my code pretty (some OCD examples of it: https://github.com/perl6/roast/blob/4ade099426/S32-io/indir.t#L65-L144 ). I think PerlTidy has an option for doing that, at least in part. > ? Thus far I haven?t built anything complicated enough to warrant figuring > out an object library; I can get by with basic hash-based structures. I?ve > read a bit about Moose and Dancer: how do they compare? And what else is > widely-used that I should consider? Well, Moose is an OO system, while Dancer is a Web framework... so comparing them is apples and oranges. Moose needs a C compiler, has expensive startup cost, and the scripts you described so far sound like Moose would be an overkill for them. There's a "lightweight" version: Moo ( https://metacpan.org/pod/Moo ) and <*shameless self-promotion*> its cousin Mew ( https://metacpan.org/pod/Mew ). Moo is easy to pick up?the basics are no harder than stock, hash-based OO?it is lightweight, needs no C compiler, and if you ever find you need more punch, you can just swap Moo to Moose and the rest of your code should just continue to work. Hope that helps. Cheers, ZZ From olaf.alders at gmail.com Thu May 4 20:03:51 2017 From: olaf.alders at gmail.com (Olaf Alders) Date: Thu, 4 May 2017 23:03:51 -0400 Subject: [tpm] Seeking advice on using Perl in a professional way In-Reply-To: References: Message-ID: <254C1089-D5F7-40A4-BA36-F530DA2FEE23@gmail.com> Hi Harold, > On May 4, 2017, at 8:24 PM, Harold Tessmann wrote: > > ? Do you run Perl::Critic on your code? I know I?ll disable some of the rules, but is it more hassle overall than it?s worth? Similarly, PerlTidy: it seems useful for generating HTML versions of documentation, but I write code in a very precise way, such it would take more time to configure it than I would save in reformatting. https://metacpan.org/pod/Code::TidyAll is an excellent tool for tidying and listing. It can handle Perl (via perltidy and Perl::Critic), JavaScript, CSS, etc. You can also easily set up pre-commit hooks so that code which needs tidying does not get committed. It really can do a lot, but even just using a part of it can really improve your workflow. Olaf From shlomif at shlomifish.org Fri May 5 03:36:05 2017 From: shlomif at shlomifish.org (Shlomi Fish) Date: Fri, 5 May 2017 13:36:05 +0300 Subject: [tpm] Seeking advice on using Perl in a professional way In-Reply-To: References: Message-ID: <20170505133605.4e202a14@telaviv1.shlomifish.org> Hi Harold, On Thu, 4 May 2017 20:24:42 -0400 Harold Tessmann wrote: > Hi from Michigan! Apologies if that?s a little far away for the Toronto > list, but the local pm.org mailing lists seems a little dead. > Hi from Tel Aviv, Israel! Regarding your questions, perhaps look into these resources: * http://perl-begin.org/tutorials/bad-elements/ * https://metacpan.org/release/Path-Tiny * https://metacpan.org/release/IO-All Other people also gave some good advice. Regards, Shlomi Fish -- ----------------------------------------------------------------- Shlomi Fish http://www.shlomifish.org/ Escape from GNU Autohell - http://www.shlomifish.org/open-source/anti/autohell/ Flock aims to be the browser for the social web, but I found it to be the completely anti-social browser. Please reply to list if it's a mailing list post - http://shlom.in/reply . From legrady at gmail.com Mon May 8 18:14:13 2017 From: legrady at gmail.com (Tom Legrady) Date: Mon, 8 May 2017 21:14:13 -0400 Subject: [tpm] Seeking advice on using Perl in a professional way In-Reply-To: References: Message-ID: <70f572ae-9320-a0f5-0a4c-80532cfc7e34@gmail.com> Boilerplate irritates me. I dislike starting every script with "use warnings; use strict" etc. So I came up with a module Boilerplate.pm. I've thought about putting it on CPAN, but it needs to change depending on the version of Perl you're using, and everyone would want their own variant. You can see what antique version of Perl I'm using .. this is the "modern" replacement for what's currently running on 5.6.1 - thanks Red Hat. I probably shouldn't have utf8 in there, I don't think utf8 characters are going to get into stock & bond names, cusips, isins, and this week we were warned of the errors that can arise from combining utf8 & \d regex. Since you mention PerlCritic, I used to create constants for punctuation characters, since PerlCritic warns you about them. And I do like the idea of defining constants at the top, rather than littering punctuation throughout the code. Since I was inconsistent about definition names, I wound up defining punctuation and the IO modes here as well. I'm still hoping to switch to a modern version of Perl, in which case there will be a longer list of modules, some of them different ... oh, to enable signatures and postderef! package Boilerplate; use warnings; use strict; use utf8; use 5.010; use autodie; use Carp; use Data::Dumper; use English '-no_match_vars'; use FindBin '$Bin'; use File::Basename; # All the variables defined in English my @PERL_VARS = qw( ACCUMULATOR ARG BASETIME CHILD_ERROR ... WARNING ); sub import { warnings->import(); strict->import; feature->import(':5.010'); autodie->import(); English->import('-no_match_vars'); FindBin->import('$Bin'); our $PUNC = ( ampersand => q{&}, at => q{@}, backslash => q{\\}, ... underscore => q{_} ); our %IO = ( append => q{>>}, delreadwrite => q{>+}, pipe_from => q{-|}, pipe_to => q{|-} read => q{<}, readwrite => q{+<}, write => q{>} ); my $caller = caller(0); do { no strict 'refs'; *{"$caller\:\:Bin"} = *{"FindBin::Bin}; # and similar for Dumper, IO, PUNC *{"$caller\:\:$_"} = *{"English\:\:$_"} for @PERL_VARS; } } I should probably have used *{"${caller}::Bin"} rather than escaping the colons, but it didn't occur to me at the time. On 2017-05-04 08:24 PM, Harold Tessmann wrote: > Hi from Michigan! Apologies if that?s a little far away for the > Toronto list, but the local pm.org mailing lists seems > a little dead. > > I'm looking to productionize some Perl scripts, and as such, I want to > adopt more structure than I use in disposable scripts. These scripts > would be used within the bounds of my employer, not released to the > general public (with maybe one or two exceptions). I know > that TIMTOWTDI, but I like the ?sometimes consistency is not a bad > thing either? extension when it comes to common problems such as > command-line option parsing, and the perldocs don?t go in depth on > what people use in the real world. I?m looking for advice on topics > including, but not limited to: > > ? Modern Perl: I like it in general, and I can install it on my team?s > machines. Are there reasons I shouldn?t use it? > > ? Does anybody have a suggestion for a good blank script template? For > instance, I know I want "use Modern::Perl 'version';" or "use > warnings/strict;", etc., but there?s probably other things I would > want in a basic script. I?ve handled this in a sort of ad-hoc manner, > growing new scripts based on what I learned from the old, but I?d like > to build a good template once and be done with it. I?d also like the > template to include documentation, and that raises more questions. Is > there a reason to put my pod block near the top vs. the bottom? > Getopt::Tiny seems nice, including a feature to automagically build a > usage block?should I use that or is there a reason to avoid it? Or is > there a better option parser? > > ? Do you run Perl::Critic on your code? I know I?ll disable some of > the rules, but is it more hassle overall than it?s worth? Similarly, > PerlTidy: it seems useful for generating HTML versions of > documentation, but I write code in a very precise way, such it would > take more time to configure it than I would save in reformatting. > > ? Thus far I haven?t built anything complicated enough to warrant > figuring out an object library; I can get by with basic hash-based > structures. I?ve read a bit about Moose and Dancer: how do they > compare? And what else is widely-used that I should consider? > > Any advice is greatly appreciated. > > Thanks, > Harold > > > _______________________________________________ > toronto-pm mailing list > toronto-pm at pm.org > http://mail.pm.org/mailman/listinfo/toronto-pm -------------- next part -------------- An HTML attachment was scrubbed... URL: From dave.s.doyle at gmail.com Tue May 23 10:43:58 2017 From: dave.s.doyle at gmail.com (Dave Doyle) Date: Tue, 23 May 2017 13:43:58 -0400 Subject: [tpm] This months meeting Message-ID: Hiyo! So, I have switched jobs and I'm still in the process of getting the venue secured and I don't think it'll be this week. I can probably have it set for Wednesday of next week if that's cool with everyone though I do have to reach out to my speaker and see if that's cool. Regards, D -- dave.s.doyle at gmail.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From arocker at Vex.Net Tue May 30 13:00:00 2017 From: arocker at Vex.Net (arocker at Vex.Net) Date: Tue, 30 May 2017 16:00:00 -0400 Subject: [tpm] Do we have a meeting tomorrow? Message-ID: <9a46144ac3fd765404402dc16f353347.squirrel@webmail.vybenetworks.com> If so, where? From olaf.alders at gmail.com Wed May 31 14:19:32 2017 From: olaf.alders at gmail.com (Olaf Alders) Date: Wed, 31 May 2017 17:19:32 -0400 Subject: [tpm] Do we have a meeting tomorrow? In-Reply-To: <9a46144ac3fd765404402dc16f353347.squirrel@webmail.vybenetworks.com> References: <9a46144ac3fd765404402dc16f353347.squirrel@webmail.vybenetworks.com> Message-ID: <2101C908-CC05-4559-B7D0-12C6828B2DB9@gmail.com> I don't think anyone responded publicly to Dave's email about scheduling the next meeting for this week. Looks like no meeting this month? Olaf > On May 30, 2017, at 4:00 PM, arocker at Vex.Net wrote: > > > If so, where? > _______________________________________________ > toronto-pm mailing list > toronto-pm at pm.org > http://mail.pm.org/mailman/listinfo/toronto-pm From dave.s.doyle at gmail.com Wed May 31 15:19:12 2017 From: dave.s.doyle at gmail.com (Gmail) Date: Wed, 31 May 2017 18:19:12 -0400 Subject: [tpm] Do we have a meeting tomorrow? In-Reply-To: <2101C908-CC05-4559-B7D0-12C6828B2DB9@gmail.com> References: <9a46144ac3fd765404402dc16f353347.squirrel@webmail.vybenetworks.com> <2101C908-CC05-4559-B7D0-12C6828B2DB9@gmail.com> Message-ID: Yeah. Nothing this month. Couldn't secure the venue and speaker. Have June's sorted. Doug Hoyte will be giving a talk. Last Wednesday (sorry, can't do thurs) -- dave.s.doyle at gmail.com Sent from my iPhone > On May 31, 2017, at 5:19 PM, Olaf Alders wrote: > > I don't think anyone responded publicly to Dave's email about scheduling the next meeting for this week. Looks like no meeting this month? > > Olaf > > >> On May 30, 2017, at 4:00 PM, arocker at Vex.Net wrote: >> >> >> If so, where? >> _______________________________________________ >> toronto-pm mailing list >> toronto-pm at pm.org >> http://mail.pm.org/mailman/listinfo/toronto-pm > _______________________________________________ > toronto-pm mailing list > toronto-pm at pm.org > http://mail.pm.org/mailman/listinfo/toronto-pm From legrady at gmail.com Wed May 31 15:42:42 2017 From: legrady at gmail.com (Tom Legrady) Date: Wed, 31 May 2017 18:42:42 -0400 Subject: [tpm] Do we have a meeting tomorrow? In-Reply-To: References: <9a46144ac3fd765404402dc16f353347.squirrel@webmail.vybenetworks.com> <2101C908-CC05-4559-B7D0-12C6828B2DB9@gmail.com> Message-ID: Any chance of getting Damien in July? I need my annual brain-frying. On 2017-05-31 06:19 PM, Gmail wrote: > Yeah. Nothing this month. Couldn't secure the venue and speaker. Have June's sorted. Doug Hoyte will be giving a talk. Last Wednesday (sorry, can't do thurs) > > -- > dave.s.doyle at gmail.com > > Sent from my iPhone > >> On May 31, 2017, at 5:19 PM, Olaf Alders wrote: >> >> I don't think anyone responded publicly to Dave's email about scheduling the next meeting for this week. Looks like no meeting this month? >> >> Olaf >> >> >>> On May 30, 2017, at 4:00 PM, arocker at Vex.Net wrote: >>> >>> >>> If so, where? >>> _______________________________________________ >>> toronto-pm mailing list >>> toronto-pm at pm.org >>> http://mail.pm.org/mailman/listinfo/toronto-pm >> _______________________________________________ >> toronto-pm mailing list >> toronto-pm at pm.org >> http://mail.pm.org/mailman/listinfo/toronto-pm > _______________________________________________ > toronto-pm mailing list > toronto-pm at pm.org > http://mail.pm.org/mailman/listinfo/toronto-pm From jkeenan at pobox.com Wed May 31 15:56:15 2017 From: jkeenan at pobox.com (James E Keenan) Date: Wed, 31 May 2017 18:56:15 -0400 Subject: [tpm] Do we have a meeting tomorrow? In-Reply-To: References: <9a46144ac3fd765404402dc16f353347.squirrel@webmail.vybenetworks.com> <2101C908-CC05-4559-B7D0-12C6828B2DB9@gmail.com> Message-ID: <5200800e-09dd-9474-6a3b-4b4211c98234@pobox.com> On 05/31/2017 06:42 PM, Tom Legrady wrote: > Any chance of getting Damien in July? I need my annual brain-frying. > You could, of course, venture south of the border to The Perl Conference/North America in Alexandria, VA. I see three listings for Mr Conway at http://www.perlconference.us/tpc-2017-dc/talks/ Hope to see some of you there! jimk