Re: 答复: the question of one program
From: Philip Potter philip.g.pot...@gmail.com 2009/11/20 gaochong zjgaoch...@gmail.com: Thanks . But the code is from cpan.org ,and is crappy ,where I will go ? CPAN has no quality control. There is no guarantee that anything you get from CPAN will not be, as you say, crappy. As a result, be selective with what you download from CPAN. Ask questions, go by reputation, check that the module is maintained (if it hasn't been updated since 2003, the owner clearly doesn't care about it much any more), Don't look at the last release date! Rather at the age of the oldest opened bug report in RT. The module may well be complete enough and bugfree enough that there is no need to release new versions. Jenda = je...@krynicky.cz === http://Jenda.Krynicky.cz = When it comes to wine, women and song, wizards are allowed to get drunk and croon as much as they like. -- Terry Pratchett in Sourcery -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
答复: the question of one program
how to get the env of one PID . my $file=/proc/1/environ; system xxd $file; open FILE, $file or die open $file err:$!; my $c=FILE; close FILE; my $hex=unpack H*,$c; print \n$hex\n\n; my @list=split /00/,$hex; foreach (@list) { print pack (H*,$_) . \n; } -邮件原件- 发件人: Shlomi Fish [mailto:shlo...@iglu.org.il] 发送时间: 2009年11月19日 23:24 收件人: beginners@perl.org 抄送: gaochong 主题: Re: the question of one program On Thursday 19 Nov 2009 16:54:00 gaochong wrote: Now I have see the following page ,but I have some question and need help . http://www.cpan.org/authors/id/S/SU/SUJAI/Process-Detail-0.1.pl From a quick look, this script seems awful: 1. No use strict; and use warnings;. 2. uses Switch.pm. 3. Uses bareword file-handles. 4. No three-args open. I would suggest to avoid using it because it's not modern perl. first,what is the meaning of if($pcs =~ /(\d+)/ $pcs =~ /\./) ,I can’t understand the re /\./ . matches any character (except possibly newline, etc., but sometimes also that if you use m{...}s). \. inside a regex matches an actual . (period, dot, full stop etc. - http://en.wikipedia.org/wiki/Full_stop ) sub hidden { print \n##Hidden processlist###\n\n; foreach $pcs (readdir(DIR)) { if($pcs =~ /(\d+)/ $pcs =~ /\./) { detailedview($pcs); } } } the second , @array=split(/([A-Z]+(_|[A-Z])+\=.[^A-Z]+)/,$_); also the re \=.[^A-Z]+ what’s it ? \= is an actual =. A = would be fine here, too. . is any character except a newline. [^A-Z] is any character except the uppercase Latin ASCII letters (A, B, C...Z). + is one or more when applied to the suffix. You can see signs of ancient perl in this expression, because it uses several capturing parentheses ((...)) instead of clustering ones ((?:...)). http://www.shlomifish.org/lecture/Perl/Newbies/lecture2/regexps/next_step. html open(FILE,$envir); This should better be: open my $file, , $envir or die $!; This script is horrible. Avoid it. Regards, Shlomi Fish while(FILE) { @array=split(/([A-Z]+(_|[A-Z])+\=.[^A-Z]+)/,$_); thanks -- - Shlomi Fish http://www.shlomifish.org/ http://www.shlomifish.org/humour/ways_to_do_it.html Chuck Norris read the entire English Wikipedia in 24 hours. Twice. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: 答复: the question of one program
2009/11/20 gaochong zjgaoch...@gmail.com: Thanks . But the code is from cpan.org ,and is crappy ,where I will go ? CPAN has no quality control. There is no guarantee that anything you get from CPAN will not be, as you say, crappy. As a result, be selective with what you download from CPAN. Ask questions, go by reputation, check that the module is maintained (if it hasn't been updated since 2003, the owner clearly doesn't care about it much any more), check the pod: good, comprehensive documentation is an indicator that the underlying code is also good (although some good code is badly documented, one rarely sees bad code well documented). Phil -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
the question of one program
Now I have see the following page ,but I have some question and need help . http://www.cpan.org/authors/id/S/SU/SUJAI/Process-Detail-0.1.pl first,what is the meaning of if($pcs =~ /(\d+)/ $pcs =~ /\./) ,I can’t understand the re /\./ sub hidden { print \n##Hidden processlist###\n\n; foreach $pcs (readdir(DIR)) { if($pcs =~ /(\d+)/ $pcs =~ /\./) { detailedview($pcs); } } } the second , @array=split(/([A-Z]+(_|[A-Z])+\=.[^A-Z]+)/,$_); also the re \=.[^A-Z]+ what’s it ? open(FILE,$envir); while(FILE) { @array=split(/([A-Z]+(_|[A-Z])+\=.[^A-Z]+)/,$_); thanks
Re: the question of one program
first,what is the meaning of if($pcs =~ /(\d+)/ $pcs =~ /\./) , $pc should contain at least 1 or more digits and it should also contain a decimal point i.e '.' I can’t understand the re /\./ It is escaping the dot character i.e '.' - thus normal behaviour of '.' to match a single character won't take place and '.' would be matched literally. Cheers, Parag 2009/11/19 gaochong zjgaoch...@gmail.com Now I have see the following page ,but I have some question and need help . http://www.cpan.org/authors/id/S/SU/SUJAI/Process-Detail-0.1.pl first,what is the meaning of if($pcs =~ /(\d+)/ $pcs =~ /\./) ,I can’t understand the re /\./ sub hidden { print \n##Hidden processlist###\n\n; foreach $pcs (readdir(DIR)) { if($pcs =~ /(\d+)/ $pcs =~ /\./) { detailedview($pcs); } } } the second , @array=split(/([A-Z]+(_|[A-Z])+\=.[^A-Z]+)/,$_); also the re \=.[^A-Z]+ what’s it ? open(FILE,$envir); while(FILE) { @array=split(/([A-Z]+(_|[A-Z])+\=.[^A-Z]+)/,$_); thanks
Re: the question of one program
On Thursday 19 Nov 2009 16:54:00 gaochong wrote: Now I have see the following page ,but I have some question and need help . http://www.cpan.org/authors/id/S/SU/SUJAI/Process-Detail-0.1.pl From a quick look, this script seems awful: 1. No use strict; and use warnings;. 2. uses Switch.pm. 3. Uses bareword file-handles. 4. No three-args open. I would suggest to avoid using it because it's not modern perl. first,what is the meaning of if($pcs =~ /(\d+)/ $pcs =~ /\./) ,I can’t understand the re /\./ . matches any character (except possibly newline, etc., but sometimes also that if you use m{...}s). \. inside a regex matches an actual . (period, dot, full stop etc. - http://en.wikipedia.org/wiki/Full_stop ) sub hidden { print \n##Hidden processlist###\n\n; foreach $pcs (readdir(DIR)) { if($pcs =~ /(\d+)/ $pcs =~ /\./) { detailedview($pcs); } } } the second , @array=split(/([A-Z]+(_|[A-Z])+\=.[^A-Z]+)/,$_); also the re \=.[^A-Z]+ what’s it ? \= is an actual =. A = would be fine here, too. . is any character except a newline. [^A-Z] is any character except the uppercase Latin ASCII letters (A, B, C...Z). + is one or more when applied to the suffix. You can see signs of ancient perl in this expression, because it uses several capturing parentheses ((...)) instead of clustering ones ((?:...)). http://www.shlomifish.org/lecture/Perl/Newbies/lecture2/regexps/next_step.html open(FILE,$envir); This should better be: open my $file, , $envir or die $!; This script is horrible. Avoid it. Regards, Shlomi Fish while(FILE) { @array=split(/([A-Z]+(_|[A-Z])+\=.[^A-Z]+)/,$_); thanks -- - Shlomi Fish http://www.shlomifish.org/ http://www.shlomifish.org/humour/ways_to_do_it.html Chuck Norris read the entire English Wikipedia in 24 hours. Twice. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: the question of one program
Shlomi Fish wrote: On Thursday 19 Nov 2009 16:54:00 gaochong wrote: Now I have see the following page ,but I have some question and need help . http://www.cpan.org/authors/id/S/SU/SUJAI/Process-Detail-0.1.pl the second , @array=split(/([A-Z]+(_|[A-Z])+\=.[^A-Z]+)/,$_); also the re \=.[^A-Z]+ what’s it ? \= is an actual =. A = would be fine here, too. . is any character except a newline. [^A-Z] is any character except the uppercase Latin ASCII letters (A, B, C...Z). + is one or more when applied to the suffix. You can see signs of ancient perl in this expression, because it uses several capturing parentheses ((...)) instead of clustering ones ((?:...)). Capturing parentheses in a split() regular expression returns the contents of the capturing parentheses as well as the strings that didn't match the regular expression so using non-capturing parentheses would do something completely different. That being said, I agree wholeheartedly that this is one crappy Perl program and should be avoided. John -- The programmer is fighting against the two most destructive forces in the universe: entropy and human stupidity. -- Damian Conway -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
答复: the question of one program
thanks all . But from the view of SA,I have not understand how to get the hidden processes in os linux . and how to get the env of every process . thanks -邮件原件- 发件人: John W. Krahn [mailto:jwkr...@shaw.ca] 发送时间: 2009年11月19日 23:53 收件人: Perl Beginners 主题: Re: the question of one program Shlomi Fish wrote: On Thursday 19 Nov 2009 16:54:00 gaochong wrote: Now I have see the following page ,but I have some question and need help . http://www.cpan.org/authors/id/S/SU/SUJAI/Process-Detail-0.1.pl the second , @array=split(/([A-Z]+(_|[A-Z])+\=.[^A-Z]+)/,$_); also the re \=.[^A-Z]+ what’s it ? \= is an actual =. A = would be fine here, too. . is any character except a newline. [^A-Z] is any character except the uppercase Latin ASCII letters (A, B, C...Z). + is one or more when applied to the suffix. You can see signs of ancient perl in this expression, because it uses several capturing parentheses ((...)) instead of clustering ones ((?:...)). Capturing parentheses in a split() regular expression returns the contents of the capturing parentheses as well as the strings that didn't match the regular expression so using non-capturing parentheses would do something completely different. That being said, I agree wholeheartedly that this is one crappy Perl program and should be avoided. John -- The programmer is fighting against the two most destructive forces in the universe: entropy and human stupidity. -- Damian Conway -- 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/
答复: the question of one program
Thanks . But the code is from cpan.org ,and is crappy ,where I will go ? -邮件原件- 发件人: John W. Krahn [mailto:jwkr...@shaw.ca] 发送时间: 2009年11月19日 23:53 收件人: Perl Beginners 主题: Re: the question of one program Shlomi Fish wrote: On Thursday 19 Nov 2009 16:54:00 gaochong wrote: Now I have see the following page ,but I have some question and need help . http://www.cpan.org/authors/id/S/SU/SUJAI/Process-Detail-0.1.pl the second , @array=split(/([A-Z]+(_|[A-Z])+\=.[^A-Z]+)/,$_); also the re \=.[^A-Z]+ what’s it ? \= is an actual =. A = would be fine here, too. . is any character except a newline. [^A-Z] is any character except the uppercase Latin ASCII letters (A, B, C...Z). + is one or more when applied to the suffix. You can see signs of ancient perl in this expression, because it uses several capturing parentheses ((...)) instead of clustering ones ((?:...)). Capturing parentheses in a split() regular expression returns the contents of the capturing parentheses as well as the strings that didn't match the regular expression so using non-capturing parentheses would do something completely different. That being said, I agree wholeheartedly that this is one crappy Perl program and should be avoided. John -- The programmer is fighting against the two most destructive forces in the universe: entropy and human stupidity. -- Damian Conway -- 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: ìö` : the question of one program
At 11:48 AM +0800 11/20/09, gaochong wrote: Thanks . But the code is from cpan.org ,and is crappy ,where I will go ? You figure out what is wrong with it and improve it. You have already been given some hints from people on this list. Here are some more: 1. Don't call subroutines with the '' character. 2. Don't quote variables unnecessarily. 3. Don't capture in regular expressions if you do not use the captured strings. 4. Don't use string comparison operators to compare numbers. 5. Use a little more horizontal whitespace and a little less vertical whitespace. Does the program do what you want it to do? If not, then let us know how it differs from your expectations. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/