Re: Using different libraries dynamically
On Sep 12, 2012, at 9:18 AM, Mark Haney wrote: > My question is, what IS standard practice for this? I use a few different methods. One is to make the changes on the dev box, then use BBEdit to "Compare" that to the file used on the live server. BBEdit allows me to copy just the lines of code I want to the live file and save it. If I have reason to worry that using FTP to save a file might corrupt a users experience with the app then I make a copy of the changed file with a new name and upload it to the live server and "rename" it the same as the live file. I I'm doing this often I make a script and run it on the server: rename("../myCode.pl-new","../myCode.pi") or die("Error 2: $!"); Now, from what I understand, and I am sure others here will correct me if I am wrong, this makes the change on the "Atomic level" and it will not interrupt your app. Kindest Regards, Bill Stephenson -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: Using different libraries dynamically
On Wed, 12 Sep 2012 10:18:49 -0400, Mark Haney wrote: > I've got what I hope is an easy question to answer. I've got a perl web > app that I've setup with a 'live' version (more like a beta actually) > and a dev version for me to make changes to that might break the other > site. > > The way I inherited it was as a single site using 'use lib' with the > library files to a working site being used as the dev version. I've > moved the files around to match the first paragraph setup. Two > different sets of files, one live the other development. > > For the time being I've manually change the 'use lib' statement before > uploading the changed/fixed code to the live site, but this is getting a > bit silly, not to mention completely not standard practice. > > My question is, what IS standard practice for this? Honestly, I've > never built a web app in this manner despite writing a lot of perl code. > So? What should I do? Any suggestions are appreciated. If the dev site and live site are on different filesystems and each doesn't share the other's path, then just put both directories in the use lib argument. That's a bit fragile, though, because one day they might both exist on the same system. What I do is have a module that figures out whether I'm in dev or prod; I use it before the use lib and get a value back that I can use to switch which path to fetch. Something like (pseudo code, untested): use MyEnv; # Sets $MyEnv::Env_Type BEGIN { require lib; lib->import( $MyEnv::Env eq 'dev' ? '/path/to/dev' : '/path/to/prod' ); } -- Peter Scott http://www.perlmedic.com/ http://www.perldebugged.com/ http://www.informit.com/store/product.aspx?isbn=0137001274 http://www.oreillyschool.com/certificates/perl-programming.php -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: Help with the can() method
Sorry this is just my typo. 于 12-9-12 下午10:10, Paul Anderson 写道: Did you copy and paste that code? Do you know that when calling can() you are using $ojb instead of $obj? Paul Anderson -- VE3HOP -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: Using different libraries dynamically
On 09/12/2012 10:57 AM, Rob Dixon wrote: Hey Mark I suggest you use set the MYLIBPATH environment variable to the directory you want to use and then do use lib $ENV{MYLIBPATH} at the head of your program HTH, Rob Thanks Rob, I'll look into it. -- Mark Haney Software Developer/Consultant AB Emblem ma...@abemblem.com Linux marius.homelinux.org 3.5.1-1.fc17.x86_64 GNU/Linux -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: Recommendations for emacs customizations for editing Perl
I haven't had any trouble. I think IIRC it may be confused a little by given/when, but not badly. Paul Anderson -- VE3HOP On 2012-09-12, at 12:20 PM, Vic Sage wrote: > > On Sep 12, 2012, at 5:59 AM, Paul Anderson wrote: > >> Install PDE from CPAN and it'll work alright. It works fine for me on >> 5.16.1. > > So it does. > > I was concerned that PDE hadn't been updated in four years. But I gather it > works well with all the recent syntax? > > V > > -- > To unsubscribe, e-mail: beginners-unsubscr...@perl.org > For additional commands, e-mail: beginners-h...@perl.org > http://learn.perl.org/ > > -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: Recommendations for emacs customizations for editing Perl
On Sep 12, 2012, at 5:59 AM, Paul Anderson wrote: > Install PDE from CPAN and it'll work alright. It works fine for me on 5.16.1. So it does. I was concerned that PDE hadn't been updated in four years. But I gather it works well with all the recent syntax? V -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: Using different libraries dynamically
On 12/09/2012 15:18, Mark Haney wrote: I've got what I hope is an easy question to answer. I've got a perl web app that I've setup with a 'live' version (more like a beta actually) and a dev version for me to make changes to that might break the other site. The way I inherited it was as a single site using 'use lib' with the library files to a working site being used as the dev version. I've moved the files around to match the first paragraph setup. Two different sets of files, one live the other development. For the time being I've manually change the 'use lib' statement before uploading the changed/fixed code to the live site, but this is getting a bit silly, not to mention completely not standard practice. My question is, what IS standard practice for this? Honestly, I've never built a web app in this manner despite writing a lot of perl code. So? What should I do? Any suggestions are appreciated. Hey Mark I suggest you use set the MYLIBPATH environment variable to the directory you want to use and then do use lib $ENV{MYLIBPATH} at the head of your program HTH, Rob -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: Using different libraries dynamically
On Wed, 12 Sep 2012 10:18:49 -0400 Mark Haney wrote: > My question is, what IS standard practice for this? The standard practice is to ensure that the development, test, and production environments are exactly the same. Even the smallest difference can cause no end of problems. -- Just my 0.0002 million dollars worth, Shawn Programming is as much about organization and communication as it is about coding. _Perl links_ official site : http://www.perl.org/ beginners' help : http://learn.perl.org/faq/beginners.html advance help: http://perlmonks.org/ documentation : http://perldoc.perl.org/ news: http://perlsphere.net/ repository : http://www.cpan.org/ blog: http://blogs.perl.org/ regional groups : http://www.pm.org/ -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Using different libraries dynamically
I've got what I hope is an easy question to answer. I've got a perl web app that I've setup with a 'live' version (more like a beta actually) and a dev version for me to make changes to that might break the other site. The way I inherited it was as a single site using 'use lib' with the library files to a working site being used as the dev version. I've moved the files around to match the first paragraph setup. Two different sets of files, one live the other development. For the time being I've manually change the 'use lib' statement before uploading the changed/fixed code to the live site, but this is getting a bit silly, not to mention completely not standard practice. My question is, what IS standard practice for this? Honestly, I've never built a web app in this manner despite writing a lot of perl code. So? What should I do? Any suggestions are appreciated. -- Mark Haney Software Developer/Consultant AB Emblem ma...@abemblem.com Linux marius.homelinux.org 3.5.1-1.fc17.x86_64 GNU/Linux -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: Help with the can() method
Did you copy and paste that code? Do you know that when calling can() you are using $ojb instead of $obj? Paul Anderson -- VE3HOP On 2012-09-12, at 9:17 AM, pangj wrote: > Hi, > > Today I wrote a script for validate a dns record from the specified DNS > server, the subroutine is: > > sub validate_dns { >my $host = shift; # a host, for example, www.google.com >my $value = shift; # the host's DNS value, may be a CNAME or an iP > address >my $dns = shift; # DNS server, for example, 8.8.8.8 > >my $method = $value =~ /^\d+\.\d+\.\d+\.\d+$/ ? "address" : "cname"; >my $res = Net::DNS::Resolver->new(nameservers => [$dns]); >my $answer = $res->query($host); > >if (defined $answer) { >return 1 if ($answer->answer)[0]->$method eq $value; >} > >return 0; > } > > Sometime the $host's value is an A record, thus it has a address() method. > Sometime the $host's value is a CNAME record, it has a cname() method. > When calling the subroutine abve with the wrong arguments, it will cause > warnings. > For example, > validate_dns("www.nsbeta.info","1.2.3.4","8.8.8.8"); > This will throw up warnings, because www.nsbeta.info is a CNAME but the > subroutine calls address() method which belongs to the A record. > > So I modified the subroutine as: > > sub validate_dns { >my $host = shift; >my $value = shift; >my $dns = shift; > >my $res = Net::DNS::Resolver->new(nameservers => [$dns]); >my $answer = $res->query($host); > >if (defined $answer) { > my $obj = ($answer->answer)[0]; > if ($ojb->can("address") ) { > return 1 if $obj->address eq $value; > } elsif ($ojb->can("cname") ) { > return 1 if $obj->cname eq $value; > } >} > >return 0; > } > > This totally can't work, it seems $obj->can() method has no effect. > What's wrong with my code? thanks. > > > -- > To unsubscribe, e-mail: beginners-unsubscr...@perl.org > For additional commands, e-mail: beginners-h...@perl.org > http://learn.perl.org/ > > -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: Recommendations for emacs customizations for editing Perl
Another thing to look out for in PDE is a line like: use 5.14; It appears that newer versions of perl will interpret this as version 5.140, not 5.14. You need a zero, like so: use 5.014; Then it will interpret it properly. >From my ~/.emacs: (defalias 'perl-mode 'cperl-mode) (setq cperl-hairy t) (setq cperl-auto-newline t) (add-to-list 'load-path "~/.emacs.d/pde/") (load "pde-load") Of course, I have the PDE stuff in ~/.emacs.d/pde. C-c r will run your code, as I recall if you use git C-x v v will check in your changes. C-c C-t C-b IIRC will run perltidy on the entire buffer. I recommend editing the templates that PDE uses with vi, it has stuff that emacs interprets. Created something of a nuisance when I tried using emacs to edit them. Paul Anderson -- VE3HOP On 2012-09-12, at 9:42 AM, Vic Sage wrote: > On Sep 11, 2012, at 11:45 PM, Shlomi Fish wrote: > >> > > But, yes, as Shlomi points out, I *am* looking for suggestions from > experienced Perl programmers who use - and customize - Emacs :-) > > -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: Recommendations for emacs customizations for editing Perl
On Sep 11, 2012, at 11:45 PM, Shlomi Fish wrote: > Hi pangj, > > On Wed, 12 Sep 2012 12:28:54 +0800 > pangj wrote: > >> Have been coding perl with VIM always. >> > > Good for you, but the original question was about Emacs and it is a legitimate > question. I had no idea how popular Vi/Vim was until I recently joined this company. Emacs wasn't even installed! I made a mighty effort to switch to Vim after 18 years of using Emacs, but after two months I was still making the same mistakes - the "zen" of Vi[m] just never really dawned. (It once took me six weeks of programming in C, cursing it the whole way, to realize what a waste the previous 14 years of coding assembler had been. Same for switching to Unix from MVS. I figure two months is enough to unlearn just about anything.) But, yes, as Shlomi points out, I *am* looking for suggestions from experienced Perl programmers who use - and customize - Emacs :-) V -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Help with the can() method
Hi, Today I wrote a script for validate a dns record from the specified DNS server, the subroutine is: sub validate_dns { my $host = shift; # a host, for example, www.google.com my $value = shift; # the host's DNS value, may be a CNAME or an iP address my $dns = shift; # DNS server, for example, 8.8.8.8 my $method = $value =~ /^\d+\.\d+\.\d+\.\d+$/ ? "address" : "cname"; my $res = Net::DNS::Resolver->new(nameservers => [$dns]); my $answer = $res->query($host); if (defined $answer) { return 1 if ($answer->answer)[0]->$method eq $value; } return 0; } Sometime the $host's value is an A record, thus it has a address() method. Sometime the $host's value is a CNAME record, it has a cname() method. When calling the subroutine abve with the wrong arguments, it will cause warnings. For example, validate_dns("www.nsbeta.info","1.2.3.4","8.8.8.8"); This will throw up warnings, because www.nsbeta.info is a CNAME but the subroutine calls address() method which belongs to the A record. So I modified the subroutine as: sub validate_dns { my $host = shift; my $value = shift; my $dns = shift; my $res = Net::DNS::Resolver->new(nameservers => [$dns]); my $answer = $res->query($host); if (defined $answer) { my $obj = ($answer->answer)[0]; if ($ojb->can("address") ) { return 1 if $obj->address eq $value; } elsif ($ojb->can("cname") ) { return 1 if $obj->cname eq $value; } } return 0; } This totally can't work, it seems $obj->can() method has no effect. What's wrong with my code? thanks. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: Recommendations for emacs customizations for editing Perl
On 12-Sep-2012, at 9:38, Vic Sage wrote: > I'd like to hear some recommendations from this list for customizations to > emacs for coding Perl. > > One seemingly respected site, http://emacswiki.org/emacs/PerlLanguage, has a > lot of links but unfortunately some are pretty dated. For example, the Perl > Develop Environment, http://search.cpan.org/dist/Emacs-PDE/, last updated in > 2008, wouldn't install because my version of Perl (5.16.1) was "too far out > of date." So of course the question is, how up-to-date is emacswiki.org? > > As I say, I'm running Perl 5.16.1, and emacs 24.something. I do have > cperl-mode.el, but there are also a lot of goodies out there like > variable-name completion and templates that look very useful. I mostly don't > want to be installing and troubleshooting stuff that hasn't been updated in > five years and/or isn't "generally regarded" to be top quality. > > Thanks for any pointers or even advice about what to avoid :) > > Vic I see there is Cperl mode in emacs for perl. Regards.../om -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: Recommendations for emacs customizations for editing Perl
Install PDE from CPAN and it'll work alright. It works fine for me on 5.16.1. Paul Anderson -- VE3HOP On 2012-09-12, at 12:08 AM, Vic Sage wrote: > I'd like to hear some recommendations from this list for customizations to > emacs for coding Perl. > > One seemingly respected site, http://emacswiki.org/emacs/PerlLanguage, has a > lot of links but unfortunately some are pretty dated. For example, the Perl > Develop Environment, http://search.cpan.org/dist/Emacs-PDE/, last updated in > 2008, wouldn't install because my version of Perl (5.16.1) was "too far out > of date." So of course the question is, how up-to-date is emacswiki.org? > > -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: destroy widget
Hi Irfan, On Fri, 7 Sep 2012 04:10:47 -0700 (PDT) Irfan Sayed wrote: > thanks ron. it worked! > i need plz another suggestion. > > in scrolled text window, i need text to be printed line by line > instead of bulk printing entire output. please find the attached > code. > > in code, there is line called, $t->see('end'); which makes the > focus of entire scrolled text window at the end. however, whenever > there is any line to be entered in scrolled window, it should enter > line by line and not in bulk. Can't you use a timer for doing that? See: https://metacpan.org/module/Tk::after Regards, Shlomi Fish > > something like auto scroll down whenever text is getting entered in > scrolled window > > please suggest > > regards > irfan > > > -- - Shlomi Fish http://www.shlomifish.org/ List of Portability Libraries - http://shlom.in/port-libs I’d love to change the world, but they won’t give me the source code. — Unknown Please reply to list if it's a mailing list post - http://shlom.in/reply . -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: destroy widget
i am stuck. can someone please suggest regards, irfan From: Irfan Sayed To: Ron Bergin ; Shlomi Fish ; Perl Beginners Sent: Saturday, September 8, 2012 8:10 PM Subject: Re: destroy widget please suggest regards irfan From: Irfan Sayed To: Ron Bergin Cc: Shlomi Fish ; Perl Beginners Sent: Friday, September 7, 2012 4:40 PM Subject: Re: destroy widget thanks ron. it worked! i need plz another suggestion. in scrolled text window, i need text to be printed line by line instead of bulk printing entire output. please find the attached code. in code, there is line called, $t->see('end'); which makes the focus of entire scrolled text window at the end. however, whenever there is any line to be entered in scrolled window, it should enter line by line and not in bulk. something like auto scroll down whenever text is getting entered in scrolled window please suggest regards irfan From: Ron Bergin To: Irfan Sayed Cc: Shlomi Fish ; Perl Beginners Sent: Wednesday, September 5, 2012 7:38 PM Subject: Re: destroy widget Irfan Sayed wrote: > please find the attached . > what i am looking for is, need to destroy the window $mw1 once the text > entered in scrolled text window > i just want to destroy $mw1 and not entire application > > > please suggest . > > > regards, > irfan > > > > > From: Shlomi Fish > To: Perl Beginners > Sent: Tuesday, September 4, 2012 6:07 PM > Subject: Re: destroy widget > > Hi Irfan, > > On Tue, 4 Sep 2012 05:01:11 -0700 (PDT) > Irfan Sayed wrote: > >> hi, >> >> i have following code to get the user input : >> >> $mw1 = MainWindow->new; >> Â Â $mw1->geometry( "200x100" ); >> Â Â $mw1->title("Client Workspace"); >> Â Â $mw1->Label( >> Â Â Â Â Â Â Â Â Â Â -text => "Enter the Perforce client name:" >> Â Â Â Â Â Â )->pack(-anchor=>'center'); >> Â Â Â Â Â Â > > You're looking for the ->withdraw()method. # Hide main window $mw1->withdraw(); ... ... # Sometime later in the app show main window again $mw1->deiconify(); $mw1->raise(); Ron Bergin -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/ -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/