60 PerlMonks - Newest Nodes New nodes appearing on PerlMonks http://perlmonks.org/index.pl?node_id=30175 http://blogs.law.harvard.edu/tech/rss PerlMonks Newest Nodes XML Generator 961 PerlMonks 2015-01-26 14:40:04 rss,clean Mon Jan 26 03:40:04 2015 30 20150126034004 Mon Jan 26 03:40:04 2015 http://perlmonks.org/ Anonymous Monk Object accessors with unknown data Amblikai http://perlmonks.org/index.pl?node_id=1114505 Hi Monks! I have a quick question with regards to building objects. My search keeps bringing up references to Moose et al, but i don't want to use an external object system. I'm practicing OOP with... perlquestion Mon, 26 Jan 2015 10:43:57 +0000 http://perlmonks.org/index.pl?node_id=1114505 1114505 1010915 2015-01-26 05:43:57 Amblikai NDBM problem RuntimeError http://perlmonks.org/index.pl?node_id=1114503 Dear Monks, I have RedHat 6 and Perl 5.10 shipped with it. Since a recent update NBDM fails: in my case it is an errno 17 (more precise: it is Term::Clui database that is called and fails w... perlquestion Mon, 26 Jan 2015 10:26:17 +0000 http://perlmonks.org/index.pl?node_id=1114503 1114503 1073834 2015-01-26 05:26:17 RuntimeError RFC: automating modular classes Arunbear http://perlmonks.org/index.pl?node_id=1114523 <a href="https://metacpan.org/module/Minions">Minions</a> is yet another OOP automation module, roughly similar to <a href="https://metacpan.org/module/Moo">Moo</a>, but which has the addtional goal of putting &#91;http://en.wikipedia.org/wiki/Information_hiding|Encapsulat... perlmeditation Mon, 26 Jan 2015 13:44:22 +0000 http://perlmonks.org/index.pl?node_id=1114523 1114523 298378 2015-01-26 08:44:22 Arunbear Re: How about a "reclaim your post" feature? chacham http://perlmonks.org/index.pl?node_id=1114528 If the post was made by mistake, this sounds like a great idea. However, this can then be used for other reasons too. For example, say you have a controversial post and want to know how it ... note Mon, 26 Jan 2015 14:36:21 +0000 http://perlmonks.org/index.pl?node_id=1114528 1114528 934209 2015-01-26 09:36:21 chacham Re: Object accessors with unknown data (hash) tye http://perlmonks.org/index.pl?node_id=1114527 Doesn't sound like you have anything that qualifies as a class. Sounds like you have a hash. Accessor methods named after attributes are anti-modular. Using such for ad-hoc attributes... note Mon, 26 Jan 2015 14:25:23 +0000 http://perlmonks.org/index.pl?node_id=1114527 1114527 22609 2015-01-26 09:25:23 tye Re^3: Print the string out in alternating upper and lowercase letters LiKe tHiS. Anonymous Monk http://perlmonks.org/index.pl?node_id=1114526 (a typo; /^\P{Cased}/, of course, or else it can find these annoying combining marks...)... note Mon, 26 Jan 2015 14:22:23 +0000 http://perlmonks.org/index.pl?node_id=1114526 1114526 961 2015-01-26 09:22:23 Anonymous Monk Re: The Boy Scout Rule sundialsvc4 http://perlmonks.org/index.pl?node_id=1114525 My take on opportunistic refactoring is different from the interpretation I read here. &nbsp; Rather than: I've got some time on my hands so lets go looking for something to chan... note Mon, 26 Jan 2015 14:12:10 +0000 http://perlmonks.org/index.pl?node_id=1114525 1114525 647953 2015-01-26 09:12:10 sundialsvc4 Re^3: Object accessors with unknown data Anonymous Monk http://perlmonks.org/index.pl?node_id=1114524 By the way: One advantage that an object might have over a plain hash is that typos in the column names cause errors. However, you can get that effect even with a hash, with the core module &#91;doc://... note Mon, 26 Jan 2015 13:50:46 +0000 http://perlmonks.org/index.pl?node_id=1114524 1114524 961 2015-01-26 08:50:46 Anonymous Monk Re^3: Object accessors with unknown data Anonymous Monk http://perlmonks.org/index.pl?node_id=1114522 Ok, I see what you're trying to do. Initially I wasn't sure if OO made sense, because part of the reason of having a class is that it presents a well-defined API. If the methods available on an obj... note Mon, 26 Jan 2015 13:40:05 +0000 http://perlmonks.org/index.pl?node_id=1114522 1114522 961 2015-01-26 08:40:05 Anonymous Monk Re^3: Object accessors with unknown data duelafn http://perlmonks.org/index.pl?node_id=1114521 One of the dangers with dynamic fields is the potential for collision (what if a column is titled "new"?). However, if you wish to try it out anyway, I would use ... note Mon, 26 Jan 2015 13:32:45 +0000 http://perlmonks.org/index.pl?node_id=1114521 1114521 53268 2015-01-26 08:32:45 duelafn Re^3: Object accessors with unknown data mbethke http://perlmonks.org/index.pl?node_id=1114520 To me it sounds like a hash would be a perfectly fine representation of a spreadsheet line. If you do it with dynamically created accessors, the program using the spreadsheet-line class would eithe... note Mon, 26 Jan 2015 13:24:19 +0000 http://perlmonks.org/index.pl?node_id=1114520 1114520 933574 2015-01-26 08:24:19 mbethke Re^5: how to split file with some pattern (Verilog) toolic http://perlmonks.org/index.pl?node_id=1114519 I can't reproduce your problem because I don't have your input file. Debugging 101: remove most of the code from your input file until it passes, then start adding code back in until you identify you... note Mon, 26 Jan 2015 13:24:15 +0000 http://perlmonks.org/index.pl?node_id=1114519 1114519 622051 2015-01-26 08:24:15 toolic Re^2: Print the string out in alternating upper and lowercase letters LiKe tHiS. Anonymous Monk http://perlmonks.org/index.pl?node_id=1114518 A more robust solution if you like: perl -CO -Mutf8 -E 'say map { /\P{Cased}/ ? $_ : $c++ % 2 ? lc : uc } "comme ša" =~ /(\X)/g' Of cours... note Mon, 26 Jan 2015 13:22:58 +0000 http://perlmonks.org/index.pl?node_id=1114518 1114518 961 2015-01-26 08:22:58 Anonymous Monk Re^2: Object accessors with unknown data Amblikai http://perlmonks.org/index.pl?node_id=1114517 So it's potentially not a great candidate for OOP? Basically, i'm writing a Spreadsheet to Template program. I've already done it without OOP, but i thought it'd be good to have each line... note Mon, 26 Jan 2015 13:00:21 +0000 http://perlmonks.org/index.pl?node_id=1114517 1114517 1010915 2015-01-26 08:00:21 Amblikai Re^2: Print the string out in alternating upper and lowercase letters lIkE ThIs Discipulus http://perlmonks.org/index.pl?node_id=1114516 perl -e "print map { $c++ %2 ? chr $_^' ' : chr $_ } unpack 'C*', $ARGV&#91;0&#93;" "like this" suffers the same problem of whitespace but is less redable... ;=)L* ... note Mon, 26 Jan 2015 12:43:59 +0000 http://perlmonks.org/index.pl?node_id=1114516 1114516 174111 2015-01-26 07:43:59 Discipulus Re: Print the string out in alternating upper and lowercase letters LiKe tHiS. hdb http://perlmonks.org/index.pl?node_id=1114515 "LiKe tHiS" is NOT alternating upper and lowercase letters, there is a lower case "e" followed by a lower case "t". Or is there an upper case blank inbetween? ... note Mon, 26 Jan 2015 12:34:53 +0000 http://perlmonks.org/index.pl?node_id=1114515 1114515 1021810 2015-01-26 07:34:53 hdb Re: Copy XML file, write new attributes and move the old files. poj http://perlmonks.org/index.pl?node_id=1114514 What is the schema for the XMLelementen table ? poj... note Mon, 26 Jan 2015 11:48:24 +0000 http://perlmonks.org/index.pl?node_id=1114514 1114514 221725 2015-01-26 06:48:24 poj Re^2: NDBM problem (you're using NDBM) RuntimeError http://perlmonks.org/index.pl?node_id=1114513 Thank you very much for your reply. I'll do as suggested by AnyDBM_File and reorder the preferences so NDBM does not get used unless no other choice available and delete the originally created db ... note Mon, 26 Jan 2015 11:38:01 +0000 http://perlmonks.org/index.pl?node_id=1114513 1114513 1073834 2015-01-26 06:38:01 RuntimeError Re: Object accessors with unknown data Anonymous Monk http://perlmonks.org/index.pl?node_id=1114512 It's still a bit unclear to me what exactly you want to do... perhaps you could give a short code example of how you expect a class like this to be used. (At the moment I don't see the advantage of... note Mon, 26 Jan 2015 11:20:08 +0000 http://perlmonks.org/index.pl?node_id=1114512 1114512 961 2015-01-26 06:20:08 Anonymous Monk Re^2: Object accessors with unknown data Anonymous Monk http://perlmonks.org/index.pl?node_id=1114511 But I'd suggest you don't. Classes like this are usually a sign of a problem that's either not analyzed properly or that doesn't benefit from solving it in an OO way. In any case it doesn't ex... note Mon, 26 Jan 2015 11:02:15 +0000 http://perlmonks.org/index.pl?node_id=1114511 1114511 961 2015-01-26 06:02:15 Anonymous Monk Re: Log::Log4perl and Log::Dispatch::FileRotate: Issues rotating log files based on date pattern Anonymous Monk http://perlmonks.org/index.pl?node_id=1114510 See <a href="https://rt.cpan.org/Public/Dist/Display.html?Name=Log-Dispatch-FileRotate">https://rt.cpan.org/Public/Dist/Display.html?Name=Log-Dispatch-FileRotate</a> the module needs love, there are a few patches and other tips listed, try them out... note Mon, 26 Jan 2015 10:57:59 +0000 http://perlmonks.org/index.pl?node_id=1114510 1114510 961 2015-01-26 05:57:59 Anonymous Monk Re^4: quickness is not so obvious SimonPratt http://perlmonks.org/index.pl?node_id=1114509 Its not so much that it feels like cheating, its more the impact of a module like Memoize might have on the underlying system that concerns me. It is entirely possible for an inexperienced d... note Mon, 26 Jan 2015 10:57:14 +0000 http://perlmonks.org/index.pl?node_id=1114509 1114509 1071917 2015-01-26 05:57:14 SimonPratt Re: Object accessors with unknown data mbethke http://perlmonks.org/index.pl?node_id=1114508 You could do something like this without any eval magic: my $o = Anything->new(qw/foo bar baz/); $o->bar; package Anything; use strict; use warnings; sub new { my ($class, ... note Mon, 26 Jan 2015 10:56:30 +0000 http://perlmonks.org/index.pl?node_id=1114508 1114508 933574 2015-01-26 05:56:30 mbethke Re: Object accessors with unknown data (eval, code generation) Anonymous Monk http://perlmonks.org/index.pl?node_id=1114507 I'm practicing OOP with bog standard perl for my own education! How do you write accessors for unknown attributes How does Moose <a href="https://metacpan.org/module/Mo">Mo</a> do it? &#91;doc://... note Mon, 26 Jan 2015 10:51:18 +0000 http://perlmonks.org/index.pl?node_id=1114507 1114507 961 2015-01-26 05:51:18 Anonymous Monk Re^3: Log::Log4perl and Log::Dispatch::FileRotate: Issues rotating log files based on date pattern Arunbear http://perlmonks.org/index.pl?node_id=1114506 Apologies, I saw the #!/usr/bin/perl in your code, and missed the part where you mentioned Windows. ... note Mon, 26 Jan 2015 10:50:24 +0000 http://perlmonks.org/index.pl?node_id=1114506 1114506 298378 2015-01-26 05:50:24 Arunbear Re: NDBM problem (you're using NDBM) Anonymous Monk http://perlmonks.org/index.pl?node_id=1114504 Your problem is that you're using NDBM, or Term::Clui is using it :) For a series of partial explanations see <a href="http://perldoc.perl.org/AnyDBM_File.html">AnyDBM_File</a> , <a href="http://perldoc.perl.org/NDBM_File.html">NDBM_File</a> , <a href="http://perldoc.perl.org/functions/dbmopen.html">dbmopen</a>, <a href="http://perldoc.perl.org/perlport.html">perlport</a>#&#91;doc:... note Mon, 26 Jan 2015 10:37:34 +0000 http://perlmonks.org/index.pl?node_id=1114504 1114504 961 2015-01-26 05:37:34 Anonymous Monk Re: The Boy Scout Rule flexvault http://perlmonks.org/index.pl?node_id=1114502 Hello eyepopslikeamosquito, I enjoyed your post and thanks for the research and references. I would add as a reference the boo... note Mon, 26 Jan 2015 10:25:22 +0000 http://perlmonks.org/index.pl?node_id=1114502 1114502 733061 2015-01-26 05:25:22 flexvault Re^3: CPAN Error Anonymous Monk http://perlmonks.org/index.pl?node_id=1114501 We had the same problem after a perl update from redhat. You solution worked fine. Thanx... note Mon, 26 Jan 2015 10:23:55 +0000 http://perlmonks.org/index.pl?node_id=1114501 1114501 961 2015-01-26 05:23:55 Anonymous Monk Re^2: The Boy Scout Rule Anonymous Monk http://perlmonks.org/index.pl?node_id=1114500 Yeah, using max() for two values is going overboard :) its just like using bitshifting on codethinkied ... which is just like the anon-array-dereference eyepopslikeamosquito posted .... just use the t... note Mon, 26 Jan 2015 10:20:38 +0000 http://perlmonks.org/index.pl?node_id=1114500 1114500 961 2015-01-26 05:20:38 Anonymous Monk Re^4: how to split file with some pattern (Verilog) herman4016 http://perlmonks.org/index.pl?node_id=1114499 i try the following codes but i got the error, please help! %Error: ./soc.post.PG.simple.v:9313: Module/Program/Interface reference not found: HDRDID2BWP7THVT %Error: ./soc.post.PG.simple.v... note Mon, 26 Jan 2015 10:10:58 +0000 http://perlmonks.org/index.pl?node_id=1114499 1114499 1079472 2015-01-26 05:10:58 herman4016 Re^2: The Boy Scout Rule Discipulus http://perlmonks.org/index.pl?node_id=1114498 Thanks for intersting read, unfortunately i cannot add nothing about code refactoring or reviewing because all the code i do at work is on my onw, i was never asked to write it nor someone has the abi... note Mon, 26 Jan 2015 10:10:07 +0000 http://perlmonks.org/index.pl?node_id=1114498 1114498 174111 2015-01-26 05:10:07 Discipulus Re: The Boy Scout Rule karlgoethebier http://perlmonks.org/index.pl?node_id=1114497 "Would this statement pass your code review?..." I would use List::Util by all means. See also ... note Mon, 26 Jan 2015 10:04:54 +0000 http://perlmonks.org/index.pl?node_id=1114497 1114497 1001958 2015-01-26 05:04:54 karlgoethebier