From gwadej at anomaly.org Thu Dec 4 20:39:41 2008 From: gwadej at anomaly.org (G. Wade Johnson) Date: Thu, 4 Dec 2008 22:39:41 -0600 Subject: [pm-h] No December meeting Message-ID: <20081204223941.507e7354@sovvan> As usual, Houston.pm takes December off. The load of end of year holidays and other family occasions normally makes the month too busy to manage any kind of presentation. If you have a little time between holiday meals and time with family to think about the January meeting, suggestions for a topic or volunteers for a presentation are always welcome. Happy "end of year" holidays. G. Wade -- The man who says he is willing to meet you halfway is usually a poor judge of distance. -- Laurence J. Peter From gwadej at anomaly.org Thu Dec 4 20:40:43 2008 From: gwadej at anomaly.org (G. Wade Johnson) Date: Thu, 4 Dec 2008 22:40:43 -0600 Subject: [pm-h] Perl Advent Calendar 2008 Message-ID: <20081204224043.18637048@sovvan> http://www.perladvent.org/2008/ Enjoy! G. Wade -- "any technology sufficiently advanced is indistinguishable from a Perl script." -- Programming Perl, 2nd ed. From toddr at null.net Fri Dec 19 21:01:18 2008 From: toddr at null.net (Todd Rinaldo) Date: Fri, 19 Dec 2008 23:01:18 -0600 Subject: [pm-h] Binding variables to a reference Message-ID: <748c25c20812192101q6cd6b0eaj651a6cc96e8fdbbb@mail.gmail.com> This has been driving me crazy, so I have to ask how (and/or if) this can be done. I have the below program. If you run it, bar prints out. This exemplifies how you can alter the variables that were passed to a target subroutine. substr does this but I suspect it's more a result of magic C code than magic Perl code. my $foo = 'foo'; bar($foo); print "$foo\n"; exit; sub bar { $_[0] = 'bar'; } My question, How do I do something like this and get it to print out bar? my $foo = 'foo'; bar($foo); print "$foo\n"; exit; sub bar { my \$bar = \$_[0]; $bar = 'bar'; } Todd From gwadej at anomaly.org Fri Dec 19 21:21:40 2008 From: gwadej at anomaly.org (G. Wade Johnson) Date: Fri, 19 Dec 2008 23:21:40 -0600 Subject: [pm-h] Binding variables to a reference In-Reply-To: <748c25c20812192101q6cd6b0eaj651a6cc96e8fdbbb@mail.gmail.com> References: <748c25c20812192101q6cd6b0eaj651a6cc96e8fdbbb@mail.gmail.com> Message-ID: <20081219232140.6462e9e7@sovvan> On Fri, 19 Dec 2008 23:01:18 -0600 "Todd Rinaldo" wrote: > This has been driving me crazy, so I have to ask how (and/or if) this > can be done. I have the below program. If you run it, bar prints out. > This exemplifies how you can alter the variables that were passed to a > target subroutine. substr does this but I suspect it's more a result > of magic C code than magic Perl code. Interesting question. > my $foo = 'foo'; > bar($foo); > print "$foo\n"; > exit; > > sub bar { > $_[0] = 'bar'; > } This works because $_[0] is an 'alias' for $foo when it is called. There are a few places in Perl code where we generate aliases, and this is one of them. > My question, How do I do something like this and get it to print out > bar? > > my $foo = 'foo'; > bar($foo); > print "$foo\n"; > exit; > > sub bar { > my \$bar = \$_[0]; > $bar = 'bar'; > } This does not quite work for a couple of reasons. The corrected version would be. sub bar { my $bar = \$_[0]; $$bar = 'bar'; } The variable $bar is a reference to the alias in $_[0]. We have to dereference $bar to be able to assign to what it points to. If you don't want the dereference, you can resort to one of the other places that we can get aliases, but it generates an even uglier syntax. sub baz { for my $baz ( $_[0] ) { $baz = 'baz'; } } We don't have the dereference, but now we've got a spurious for loop that is just used to get the aliasing. Normally, I just use the $_[0] syntax if I'm modifying the arguments to a sub, it is sufficiently strange that someone running across it is likely to pause and realize that something magical is happening, instead of assuming that they know what is happening. G. Wade -- Computer language design is just like a stroll in the park. Jurassic Park, that is. -- Larry Wall From gwadej at anomaly.org Sat Dec 20 08:15:15 2008 From: gwadej at anomaly.org (G. Wade Johnson) Date: Sat, 20 Dec 2008 10:15:15 -0600 Subject: [pm-h] Deparse Message-ID: <20081220101515.211aced7@sovvan> I've recently been reminded of a module that can help in understanding terse Perl code: B::Deparse. It's a compiler backend that converts Perl into Perl. This doesn't sound too useful until you see it used with the -M switch and the O module. The latest example came from Perl Monks. perl -MO=Deparse -lpe "s/^\s*\d+://;" The original questioner wanted to remove some stuff from the front of every line. The person who answered gave a one-liner without the -M switch and then suggested this for understanding. Running this on the command line gives the following: ------------------------------------------------------- BEGIN { $/ = "\n"; $\ = "\n"; } LINE: while (defined($_ = )) { chomp $_; s/^\s*\d+://; } continue { print $_; } -e syntax OK ------------------------------------------------------- Which shows what perl does, given the one-liner presented. You can also do this with whole scripts to convert some "overly terse" code into something more verbose that may be easier to understand. G. Wade -- You should never hand someone a gun unless you're sure where they'll point it. -- Jeffrey Sinclair in "By Any Means Necessary" From toddr at null.net Sun Dec 21 11:55:07 2008 From: toddr at null.net (Todd Rinaldo) Date: Sun, 21 Dec 2008 13:55:07 -0600 Subject: [pm-h] Binding variables to a reference In-Reply-To: <20081219232140.6462e9e7@sovvan> References: <748c25c20812192101q6cd6b0eaj651a6cc96e8fdbbb@mail.gmail.com> <20081219232140.6462e9e7@sovvan> Message-ID: <748c25c20812211155q6da4802fkf6efc1a6cf34bcf@mail.gmail.com> > sub baz { > for my $baz ( $_[0] ) > { > $baz = 'baz'; > } > } Ok, so short answer is there's no way to create an alias without a sub or a for loop? Which brings me to my real problem: forks::shared (http://tinyurl.com/sharedforks). I don't normally like puking the whole problem, but I'm half way down the rabbit hole on this problem. I might as well go all the way... What I'm trying to figure out: How do I use forks::shared to share variables between parent/child without an anonymous subroutine on the fork call. My design issue: I need to create a program that can quickly run commands on a remote host via SSH. I am using Net::SSH::Perl because all of the other options are buggy or abandoned. So what I was thinking was a POE server that takes requests for running a command. If it already has a SSH object open, it uses that to run the command. If not, then it creates a new object to handle the connection. The problem is that Net::SSH::Perl does not destroy properly, which means your program will slowly leak and blow up if left to run too long. I'm also unsure how many open connections a single process can stably handle. So what I'm thinking is that I can use POE to to take requests for commands and then it can maintain a list of connections it could send those commands to. It would have to fork and maintain the connections in separate processes to prevent the core program from crashing. So if I want each fork to do more than one command, I have to create a way to send requests to run commands on the child process and get back the output. Enter shared variables. The way forks and threads (the Perl modules) work is that you tell it: Thread->create(\&sub_to_call, @variables_to_pass). You can share variables by pre-declaring the variables as shared and then passing them to the target sub. The sub can then use locking, etc to alter the variable and the parent will see the changes. I can use this method to send calls and get back the resulting command. The problem is that short of using an anonymous sub, I don't see a way to pass in the shared variable to the target sub the way forks::shared is designed. You can't pass references to the child you have to pass the variable it's self. I realize I've kinda dumped here I thought it might avoid multiple email passes with me explaining to you that I was only giving you a stub, not the whole problem and your solution you suggest won't work for me. Any suggestions? From robo4288 at gmail.com Sun Dec 21 13:47:41 2008 From: robo4288 at gmail.com (Robert Boone) Date: Sun, 21 Dec 2008 15:47:41 -0600 Subject: [pm-h] Binding variables to a reference In-Reply-To: <748c25c20812211155q6da4802fkf6efc1a6cf34bcf@mail.gmail.com> References: <748c25c20812192101q6cd6b0eaj651a6cc96e8fdbbb@mail.gmail.com> <20081219232140.6462e9e7@sovvan> <748c25c20812211155q6da4802fkf6efc1a6cf34bcf@mail.gmail.com> Message-ID: <435624390812211347v19637718tb9b55b411d40273a@mail.gmail.com> I may have misunderstood and if so please disregard. But in my understanding of perl threads and the forks module is that you don't pass shard variables as arguments. You just declare them before creating the thread and use them because they're in scope. Here is a bad example: #!/usr/bin/perl use strict; use threads; use threads::shared; my $num : shared; my $end : shared; $num = 0; $end = 0; sub Boss { lock $num; $num = 5; sleep 4; lock $end; $end = 1; print "Boss: DONE!\n"; } sub Worker { while (!$end) { sleep 1; print $num. "\n"; } print "Worker: DONE!\n"; } my @hold; push @hold, threads->new( \&Boss ); push @hold, threads->new( \&Worker ); $_->join foreach (@hold); From toddr at null.net Mon Dec 22 22:22:59 2008 From: toddr at null.net (Todd Rinaldo) Date: Tue, 23 Dec 2008 00:22:59 -0600 Subject: [pm-h] Binding variables to a reference In-Reply-To: <435624390812211347v19637718tb9b55b411d40273a@mail.gmail.com> References: <748c25c20812192101q6cd6b0eaj651a6cc96e8fdbbb@mail.gmail.com> <20081219232140.6462e9e7@sovvan> <748c25c20812211155q6da4802fkf6efc1a6cf34bcf@mail.gmail.com> <435624390812211347v19637718tb9b55b411d40273a@mail.gmail.com> Message-ID: <748c25c20812222222g62fbfc3bj7243c80da834bf18@mail.gmail.com> On Sun, Dec 21, 2008 at 3:47 PM, Robert Boone wrote: > But in my understanding of perl threads and the forks module is that > you don't pass shared variables as arguments. You just declare them > before creating the thread and use them because they're in scope. Yeah, that's how I understand it too. I just feel a little dirty, like I'm going end up in global variable hell. My other concern is I'd have to do something silly like maintain hashes of variables indexed by process ID so the copious threads don't step on each other. It just seems like there has to be a better way. The only other sleeve I have would require a lot of socket maintenance. I'm not sure what would be worse. From gwadej at anomaly.org Tue Dec 30 20:24:46 2008 From: gwadej at anomaly.org (G. Wade Johnson) Date: Tue, 30 Dec 2008 22:24:46 -0600 Subject: [pm-h] January Meeting Message-ID: <20081230222446.54d18451@sovvan> In two weeks, we will be having the January Houston.pm meeting. I have been considering doing a presentation on one of two topics: * RRDtool For a project at work I have recently had to dig into this tool quite seriously. Some of the lessons I have learned might save you some trouble later. * Vim configuration for Perl users Back in June of 2008, Will Willis showed how Emacs could be a useful editor for Perl programmers. This would provide some equivalent information for users of vim. Does anyone have any interest in either of these topics? G. Wade -- $HOME is where your dotfiles are. -- Gym Quirk From will.willis at gmail.com Tue Dec 30 20:37:10 2008 From: will.willis at gmail.com (Will Willis) Date: Tue, 30 Dec 2008 22:37:10 -0600 Subject: [pm-h] January Meeting In-Reply-To: <20081230222446.54d18451@sovvan> References: <20081230222446.54d18451@sovvan> Message-ID: <6ee1e6090812302037o327a7419r1035115d0742e572@mail.gmail.com> RRDtool seems very interesting. I've got at least one project that involves graphing time series data. -Will On Tue, Dec 30, 2008 at 10:24 PM, G. Wade Johnson wrote: > In two weeks, we will be having the January Houston.pm meeting. > > I have been considering doing a presentation on one of two topics: > > * RRDtool > For a project at work I have recently had to dig into this tool > quite seriously. Some of the lessons I have learned might save you > some trouble later. > > * Vim configuration for Perl users > Back in June of 2008, Will Willis showed how Emacs could be a useful > editor for Perl programmers. This would provide some equivalent > information for users of vim. > > Does anyone have any interest in either of these topics? > > G. Wade > -- > $HOME is where your dotfiles are. -- Gym Quirk > _______________________________________________ > Houston mailing list > Houston at pm.org > http://mail.pm.org/mailman/listinfo/houston > Website: http://houston.pm.org/ > -------------- next part -------------- An HTML attachment was scrubbed... URL: From kjordan3 at gmail.com Tue Dec 30 20:41:57 2008 From: kjordan3 at gmail.com (Kevin Jordan) Date: Tue, 30 Dec 2008 22:41:57 -0600 Subject: [pm-h] January Meeting In-Reply-To: <6ee1e6090812302037o327a7419r1035115d0742e572@mail.gmail.com> References: <20081230222446.54d18451@sovvan> <6ee1e6090812302037o327a7419r1035115d0742e572@mail.gmail.com> Message-ID: I'm interested in the vim talk. -Kevin On Tue, Dec 30, 2008 at 10:37 PM, Will Willis wrote: > RRDtool seems very interesting. I've got at least one project that involves > graphing time series data. > -Will > > > On Tue, Dec 30, 2008 at 10:24 PM, G. Wade Johnson wrote: > >> In two weeks, we will be having the January Houston.pm meeting. >> >> I have been considering doing a presentation on one of two topics: >> >> * RRDtool >> For a project at work I have recently had to dig into this tool >> quite seriously. Some of the lessons I have learned might save you >> some trouble later. >> >> * Vim configuration for Perl users >> Back in June of 2008, Will Willis showed how Emacs could be a useful >> editor for Perl programmers. This would provide some equivalent >> information for users of vim. >> >> Does anyone have any interest in either of these topics? >> >> G. Wade >> -- >> $HOME is where your dotfiles are. -- Gym Quirk >> _______________________________________________ >> Houston mailing list >> Houston at pm.org >> http://mail.pm.org/mailman/listinfo/houston >> Website: http://houston.pm.org/ >> > > > _______________________________________________ > Houston mailing list > Houston at pm.org > http://mail.pm.org/mailman/listinfo/houston > Website: http://houston.pm.org/ > -------------- next part -------------- An HTML attachment was scrubbed... URL: From gwadej at anomaly.org Tue Dec 30 20:49:26 2008 From: gwadej at anomaly.org (G. Wade Johnson) Date: Tue, 30 Dec 2008 22:49:26 -0600 Subject: [pm-h] January Meeting In-Reply-To: References: <20081230222446.54d18451@sovvan> <6ee1e6090812302037o327a7419r1035115d0742e572@mail.gmail.com> Message-ID: <20081230224926.5553a552@sovvan> Great...One vote for each. You guys aren't making it easy on me, are you? More opinions? On Tue, 30 Dec 2008 22:41:57 -0600 "Kevin Jordan" wrote: > I'm interested in the vim talk. > > -Kevin > > On Tue, Dec 30, 2008 at 10:37 PM, Will Willis > wrote: > > > RRDtool seems very interesting. I've got at least one project that > > involves graphing time series data. > > -Will > > > > > > On Tue, Dec 30, 2008 at 10:24 PM, G. Wade Johnson > > wrote: > > > >> In two weeks, we will be having the January Houston.pm meeting. > >> > >> I have been considering doing a presentation on one of two topics: > >> > >> * RRDtool > >> For a project at work I have recently had to dig into this tool > >> quite seriously. Some of the lessons I have learned might save > >> you some trouble later. > >> > >> * Vim configuration for Perl users > >> Back in June of 2008, Will Willis showed how Emacs could be a > >> useful editor for Perl programmers. This would provide some > >> equivalent information for users of vim. > >> > >> Does anyone have any interest in either of these topics? > >> > >> G. Wade > >> -- > >> $HOME is where your dotfiles are. -- Gym > >> Quirk _______________________________________________ > >> Houston mailing list > >> Houston at pm.org > >> http://mail.pm.org/mailman/listinfo/houston > >> Website: http://houston.pm.org/ > >> > > > > > > _______________________________________________ > > Houston mailing list > > Houston at pm.org > > http://mail.pm.org/mailman/listinfo/houston > > Website: http://houston.pm.org/ > > -- Results are what you wanted, consequences are what you got. -- Michael VanDusen From mikeflan at att.net Wed Dec 31 04:06:41 2008 From: mikeflan at att.net (Mike Flannigan) Date: Wed, 31 Dec 2008 06:06:41 -0600 Subject: [pm-h] January Meeting In-Reply-To: <20081230222446.54d18451@sovvan> References: <20081230222446.54d18451@sovvan> Message-ID: <495B6051.5080702@att.net> Someday I plan to study data historian tools like RRDtool. Not the round robin variety, but the linear kinds that save all data, compressing the distant past data into tighter and tighter time lengths (can only get hourly averages, or daily averages, or . . . ). The typical application is storing thousands of chemical plant process variables in real time and providing access to the data. Mike G. Wade Johnson wrote: > In two weeks, we will be having the January Houston.pm meeting. > > I have been considering doing a presentation on one of two topics: > > * RRDtool > For a project at work I have recently had to dig into this tool > quite seriously. Some of the lessons I have learned might save you > some trouble later. > > * Vim configuration for Perl users > Back in June of 2008, Will Willis showed how Emacs could be a useful > editor for Perl programmers. This would provide some equivalent > information for users of vim. > > Does anyone have any interest in either of these topics? > > G. Wade > From gwadej at anomaly.org Wed Dec 31 04:55:00 2008 From: gwadej at anomaly.org (G. Wade Johnson) Date: Wed, 31 Dec 2008 06:55:00 -0600 Subject: [pm-h] January Meeting In-Reply-To: <495B6051.5080702@att.net> References: <20081230222446.54d18451@sovvan> <495B6051.5080702@att.net> Message-ID: <20081231065500.371dadec@sovvan> On Wed, 31 Dec 2008 06:06:41 -0600 Mike Flannigan wrote: > > Someday I plan to study data historian tools like RRDtool. > Not the round robin variety, but the linear kinds that save > all data, compressing the distant past data into tighter and > tighter time lengths (can only get hourly averages, or > daily averages, or . . . ). The typical application is > storing thousands of chemical plant process variables > in real time and providing access to the data. Do you know of any of that kind of tool out there? G. Wade > > G. Wade Johnson wrote: > > In two weeks, we will be having the January Houston.pm meeting. > > > > I have been considering doing a presentation on one of two topics: > > > > * RRDtool > > For a project at work I have recently had to dig into this tool > > quite seriously. Some of the lessons I have learned might save > > you some trouble later. > > > > * Vim configuration for Perl users > > Back in June of 2008, Will Willis showed how Emacs could be a > > useful editor for Perl programmers. This would provide some > > equivalent information for users of vim. > > > > Does anyone have any interest in either of these topics? > > > > G. Wade > > > _______________________________________________ > Houston mailing list > Houston at pm.org > http://mail.pm.org/mailman/listinfo/houston > Website: http://houston.pm.org/ -- There are two ways to write error-free programs; only the third one works. -- Alan Perlis From mikeflan at att.net Wed Dec 31 05:05:13 2008 From: mikeflan at att.net (Mike Flannigan) Date: Wed, 31 Dec 2008 07:05:13 -0600 Subject: [pm-h] January Meeting In-Reply-To: <20081231065500.371dadec@sovvan> References: <20081230222446.54d18451@sovvan> <495B6051.5080702@att.net> <20081231065500.371dadec@sovvan> Message-ID: <495B6E09.4050000@att.net> The one I am familiar with is PI (Plant Information) system by OSI Software. It is a commercial product, as most are. They are probably the high-end industry leaders in this area. http://www.osisoft.com/ Mike Flannigan G. Wade Johnson wrote: > On Wed, 31 Dec 2008 06:06:41 -0600 > Mike Flannigan wrote: > > >> Someday I plan to study data historian tools like RRDtool. >> Not the round robin variety, but the linear kinds that save >> all data, compressing the distant past data into tighter and >> tighter time lengths (can only get hourly averages, or >> daily averages, or . . . ). The typical application is >> storing thousands of chemical plant process variables >> in real time and providing access to the data. >> > > Do you know of any of that kind of tool out there? > > G. Wade > >> G. Wade Johnson wrote: >> >>> In two weeks, we will be having the January Houston.pm meeting. >>> >>> I have been considering doing a presentation on one of two topics: >>> >>> * RRDtool >>> For a project at work I have recently had to dig into this tool >>> quite seriously. Some of the lessons I have learned might save >>> you some trouble later. >>> >>> * Vim configuration for Perl users >>> Back in June of 2008, Will Willis showed how Emacs could be a >>> useful editor for Perl programmers. This would provide some >>> equivalent information for users of vim. >>> >>> Does anyone have any interest in either of these topics? >>> >>> G. Wade >>> >>> >> _______________________________________________ >> Houston mailing list >> Houston at pm.org >> http://mail.pm.org/mailman/listinfo/houston >> Website: http://houston.pm.org/ >> > > > From toddr at null.net Wed Dec 31 05:42:43 2008 From: toddr at null.net (Todd Rinaldo) Date: Wed, 31 Dec 2008 07:42:43 -0600 Subject: [pm-h] January Meeting In-Reply-To: <20081230224926.5553a552@sovvan> References: <20081230222446.54d18451@sovvan> <6ee1e6090812302037o327a7419r1035115d0742e572@mail.gmail.com> <20081230224926.5553a552@sovvan> Message-ID: <748c25c20812310542m76ded64dj93595bda3a4cabcb@mail.gmail.com> RRD sounds interesting to me. I'm now an official eclipse (with epic) junkie so I rarely use terminal editors. How long would the vim chat be? Can it be sandwiched in on the end? On Tue, Dec 30, 2008 at 10:49 PM, G. Wade Johnson wrote: > Great...One vote for each. You guys aren't making it easy > on me, are you? > > More opinions? > > On Tue, 30 Dec 2008 22:41:57 -0600 > "Kevin Jordan" wrote: > >> I'm interested in the vim talk. >> >> -Kevin >> >> On Tue, Dec 30, 2008 at 10:37 PM, Will Willis >> wrote: >> >> > RRDtool seems very interesting. I've got at least one project that >> > involves graphing time series data. >> > -Will >> > >> > >> > On Tue, Dec 30, 2008 at 10:24 PM, G. Wade Johnson >> > wrote: >> > >> >> In two weeks, we will be having the January Houston.pm meeting. >> >> >> >> I have been considering doing a presentation on one of two topics: >> >> >> >> * RRDtool >> >> For a project at work I have recently had to dig into this tool >> >> quite seriously. Some of the lessons I have learned might save >> >> you some trouble later. >> >> >> >> * Vim configuration for Perl users >> >> Back in June of 2008, Will Willis showed how Emacs could be a >> >> useful editor for Perl programmers. This would provide some >> >> equivalent information for users of vim. >> >> >> >> Does anyone have any interest in either of these topics? >> >> >> >> G. Wade >> >> -- >> >> $HOME is where your dotfiles are. -- Gym >> >> Quirk _______________________________________________ >> >> Houston mailing list >> >> Houston at pm.org >> >> http://mail.pm.org/mailman/listinfo/houston >> >> Website: http://houston.pm.org/ >> >> >> > >> > >> > _______________________________________________ >> > Houston mailing list >> > Houston at pm.org >> > http://mail.pm.org/mailman/listinfo/houston >> > Website: http://houston.pm.org/ >> > > > > -- > Results are what you wanted, consequences are what you got. > -- Michael VanDusen > _______________________________________________ > Houston mailing list > Houston at pm.org > http://mail.pm.org/mailman/listinfo/houston > Website: http://houston.pm.org/ > -- Todd Rinaldo toddr at null.net