Re: Perl Code
On Sat, 01 Sep 2012 04:05:31 +, Peter Scott wrote: > On 2012-08-29, at 12:46 PM, Ashwin Rao T wrote: >> 1)Check if IP address is in the range 172.125.1.0 and 172.125.25.0 >> using only return functions & regular expressions in Perl. > > /\b172\.125\.(\d+)\.((?>\d+))(??{(1<=$1 && $1<=24 && 0<=$2 && $2<=255)|| > ($1==25 && $2==0) ? "" : "(*FAIL)"})/ and say "Strictly correct answer > that shows instructor didn't think about the question" > > Do let us know what grade that gets you :-) Forgot the /a... -- 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: Perl Code
On 2012-08-29, at 12:46 PM, Ashwin Rao T wrote: > 1)Check if IP address is in the range 172.125.1.0 and 172.125.25.0 > using only return functions & regular expressions in Perl. /\b172\.125\.(\d+)\.((?>\d+))(??{(1<=$1 && $1<=24 && 0<=$2 && $2<=255)|| ($1==25 && $2==0) ? "" : "(*FAIL)"})/ and say "Strictly correct answer that shows instructor didn't think about the question" Do let us know what grade that gets you :-) -- 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: Perl Code
of course it's homework. though if the student would be so kind to inform the list what the class's (and instructor's) best answer is to #3, i'll be able to inform them whether the class is worth staying in. seriously, it's a much harder question than it seems. also, the cool way of answering #1 would be to break the ip and base address into binary, get the subnet, generate a broadcast and figure out if you're in scope or not. otoh, he didn't ask for a valid address, so there goes the coolness. oh well. #2 and #4 are shit questions. #2 is a simple regex. #4 is a lookup table. if you're going to ask homework questions here, either make sure to obscure them (ie, don't be such a dumb ass and just copy/paste) or try to solve it, if you can't, let us know what you've tried and that it's homework and you'll probably get better help (probably the better option). this time, it looks like you'll have to either hold off on the partying for a while while you figure it out or drink and be content with the fact that you're going to miss this assignment. choose. On Fri, Aug 31, 2012 at 2:25 PM, Paul Anderson wrote: > I smell homework:p > > > Paul Anderson -- VE3HOP > > On 2012-08-29, at 12:46 PM, Ashwin Rao T wrote: > >> 1)Check if IP address is in the range 172.125.1.0 and 172.125.25.0 using only >> return functions & regular expressions in Perl. >> 2)Check if the name is valid (has atleast 3 letters and one vowel) using only >> return functions and regular expressions in Perl. >> 3)Check if email address is valid using only return functions and regular >> expressions in Perl. >> 4)Convert the number into words using only return functions and regular >> expressions in Perl. (15 => one five) >> >> >> >> >> -- >> 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/ > > -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: Perl Code
I smell homework:p Paul Anderson -- VE3HOP On 2012-08-29, at 12:46 PM, Ashwin Rao T wrote: > 1)Check if IP address is in the range 172.125.1.0 and 172.125.25.0 using only > return functions & regular expressions in Perl. > 2)Check if the name is valid (has atleast 3 letters and one vowel) using only > return functions and regular expressions in Perl. > 3)Check if email address is valid using only return functions and regular > expressions in Perl. > 4)Convert the number into words using only return functions and regular > expressions in Perl. (15 => one five) > > > > > -- > 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: Perl Code
On Wed, Aug 29, 2012 at 09:59:22 -0700 , John SJ Anderson wrote: > On Wednesday, August 29, 2012 at 9:46 AM, Ashwin Rao T wrote: > > 1)Check if IP address is in the range 172.125.1.0 and 172.125.25.0 using > > only > > return functions & regular expressions in Perl. > > 2)Check if the name is valid (has atleast 3 letters and one vowel) using > > only > > return functions and regular expressions in Perl. > > 3)Check if email address is valid using only return functions and regular > > expressions in Perl. > > 4)Convert the number into words using only return functions and regular > > expressions in Perl. (15 => one five) > > > > > I'm pretty sure the instructor in the class you're taking would prefer > that you do your own homework… I'm pretty sure the instructor doesn't know Perl or regular expressions if they're asking for those things to be done with only regex. At least three items on that list are best done with CPAN modules. My advice is to drop the class now and get a refund, if at all possible. -- Chris Nehren | Coder, Sysadmin, Masochist Shadowcat Systems Ltd. | http://shadowcat.co.uk/ pgpZ0Q9z5gjRm.pgp Description: PGP signature
Re: Perl Code
On Aug 29, 2012, at 11:59 AM, John SJ Anderson wrote: > On Wednesday, August 29, 2012 at 9:46 AM, Ashwin Rao T wrote: >> 1)Check if IP address is in the range 172.125.1.0 and 172.125.25.0 using only >> return functions & regular expressions in Perl. >> 2)Check if the name is valid (has atleast 3 letters and one vowel) using only >> return functions and regular expressions in Perl. >> 3)Check if email address is valid using only return functions and regular >> expressions in Perl. >> 4)Convert the number into words using only return functions and regular >> expressions in Perl. (15 => one five) >> >> > I'm pretty sure the instructor in the class you're taking would prefer that > you do your own homework… > > j. > I think you hit it spot on there. Too funny... -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
How can I use Net::SSH2 or Net::SSH::Perl in krb5 authen env?
Hello all: I usually like to use Net::SSH2 or Net::SSH::Perl module to send commands to the cluster. But now, these servers change to be authenticated by kerberos5.When I kinit and try my old scripts, it failed! $ssh2->auth_list return "gssapi-keyex" and "gssapi-micpasswd", but nothing related in PODs of Net::SSH2/Net::SSH::Perl. Thanks for help~~
Re: printf
On Fri, 31 Aug 2012 15:28:38 +0300 "Octavian Rasnita" wrote: > From: "Torsten" > > > Hey, > > > > I found a strange behaviour for printf: If you do for example > > > > printf "%d",29/100*100 > > > > you get 28. But with > > > > printf "%d",29*100/100 > > > > it's 29. Seems to be related to rounding. > > > Yep > > use bignum; > > might help. > > Octavian > > A known problem; it's call Numerical Analysis https://en.wikipedia.org/wiki/Numerical_analysis -- 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/
Re: printf
From: "Torsten" > Hey, > > I found a strange behaviour for printf: If you do for example > > printf "%d",29/100*100 > > you get 28. But with > > printf "%d",29*100/100 > > it's 29. Seems to be related to rounding. Yep use bignum; might help. Octavian -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
printf
Hey, I found a strange behaviour for printf: If you do for example printf "%d",29/100*100 you get 28. But with printf "%d",29*100/100 it's 29. Seems to be related to rounding. The perl version is 5.10.1 on debian. Regards -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: Can not run ssh command inside perl script !
Hello Jack, On Fri, 31 Aug 2012 17:00:12 +0700 Jack Vo wrote: > Hello List, > > I'm trying to execute a script which retrieves swap usage memory in > remote host. So that I install Net::SSH::Perl module (from source > code) from CPAN website. > My script below : > > #!/usr/bin/perl -w > > use strict; > > use Net::SSH::Perl; > > > > my $hostname = "192.168.7.5"; > > my $username = "abcd"; > > my $password = "abcd"; > > > > my $cmd = "free -m"; > > > > my $ssh = Net::SSH::Perl->new("$hostname", debug=>0); > > $ssh->login("$username","$password"); > > my ($stdout,$stderr,$exit) = $ssh->cmd("$cmd"); > But the output has some error message and don't know how to solve > this problem. > > Can't locate Math/Pari.pm in @INC (@INC contains: > > /usr/lib/perl5/5.8.8/x86_64-linux-thread-multi /usr/lib/perl5/5.8.8 > > /usr/lib/perl5/site_perl/5.8.8/x86_64-linux-thread-multi > > /usr/lib/perl5/site_perl/5.8.8 /usr/lib/perl5/site_perl > > /usr/lib/perl5/vendor_perl/5.8.8/x86_64-linux-thread-multi > > /usr/lib/perl5/vendor_perl/5.8.8 /usr/lib/perl5/vendor_perl .) at > > /usr/lib/perl5/site_perl/5.8.8/Net/SSH/Perl/Util/SSH2MP.pm line 6, > > line 1. This means you need to install the Math::Pari module from CPAN or from your distribution's package repository. On rpm-based systems installing perl-Math-Pari should work. Regards, Shlomi Fish -- - Shlomi Fish http://www.shlomifish.org/ Parody of "The Fountainhead" - http://shlom.in/towtf Confucius says: “XSLT made me realise humanity was hopeless.”. 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/
Can not run ssh command inside perl script !
Hello List, I'm trying to execute a script which retrieves swap usage memory in remote host. So that I install Net::SSH::Perl module (from source code) from CPAN website. My script below : #!/usr/bin/perl -w use strict; use Net::SSH::Perl; my $hostname = "192.168.7.5"; my $username = "abcd"; my $password = "abcd"; my $cmd = "free -m"; my $ssh = Net::SSH::Perl->new("$hostname", debug=>0); $ssh->login("$username","$password"); my ($stdout,$stderr,$exit) = $ssh->cmd("$cmd"); But the output has some error message and don't know how to solve this problem. Can't locate Math/Pari.pm in @INC (@INC contains: /usr/lib/perl5/5.8.8/x86_64-linux-thread-multi /usr/lib/perl5/5.8.8 /usr/lib/perl5/site_perl/5.8.8/x86_64-linux-thread-multi /usr/lib/perl5/site_perl/5.8.8 /usr/lib/perl5/site_perl /usr/lib/perl5/vendor_perl/5.8.8/x86_64-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.8 /usr/lib/perl5/vendor_perl .) at /usr/lib/perl5/site_perl/5.8.8/Net/SSH/Perl/Util/SSH2MP.pm line 6, line 1. BEGIN failed--compilation aborted at /usr/lib/perl5/site_perl/5.8.8/Net/SSH/Perl/Util/SSH2MP.pm line 6, line 1. Compilation failed in require at /usr/lib/perl5/site_perl/5.8.8/Net/SSH/Perl/Util.pm line 56, line 1. BEGIN failed--compilation aborted at /usr/lib/perl5/site_perl/5.8.8/Net/SSH/Perl/Kex/DH1.pm line 10, line 1. Compilation failed in require at /usr/lib/perl5/site_perl/5.8.8/Net/SSH/Perl/Kex.pm line 6, line 1. BEGIN failed--compilation aborted at /usr/lib/perl5/site_perl/5.8.8/Net/SSH/Perl/Kex.pm line 6, line 1. Compilation failed in require at /usr/lib/perl5/site_perl/5.8.8/Net/SSH/Perl/SSH2.pm line 6, line 1. BEGIN failed--compilation aborted at /usr/lib/perl5/site_perl/5.8.8/Net/SSH/Perl/SSH2.pm line 6, line 1. Compilation failed in require at /usr/lib/perl5/site_perl/5.8.8/Net/SSH/Perl.pm line 52, line 1. Did I miss install Math module ? This is modules which already installed in server. perl-32bit-5.8.8-14.10 perl-Parse-RecDescent-1.80-259.2 perl-Crypt-SmbHash-0.12-13.2 perl-DBD-SQLite-1.11-14.6 perl-Config-IniFiles-2.39-13.4 perl-URI-1.35-15.2 perl-X500-DN-0.28-133.2 perl-Date-Calc-5.4-14.5 perl-Config-Crontab-1.11-12.2 perl-File-Tail-0.99.3-12.2 perl-TimeDate-1.16-136.2 perl-gettext-1.05-13.2 perl-DBI-1.50-13.2 perl-Compress-Zlib-1.35-14.2 perl-Digest-SHA1-2.10-15.2 perl-TermReadKey-2.30-13.2 perl-XML-Writer-0.600-13.2 perl-PlRPC-0.2018-13.2 perl-Bootloader-0.4.19.21-0.4.12 perl-Carp-Clan-5.3-13.5 perl-Digest-MD4-1.5-13.2 perl-XML-Parser-2.34-43.2 perl-Net-Daemon-0.38-61.2 perl-libapparmor-2.2-0.3 perl-Bit-Vector-6.4-13.5 - Some Information : OS : SUSE Linux SP3. Perl version : perl-5.8.8-14.10 Any help is greatly appriciated. -- Thank and best regards, Jack Vo