mkdir in the mounted partition,please h elp me,thanks
#!/usr/bin/perl -w #Auther:gaochong use strict; my @list = (3 .. 9); my @FA=("FA0001".."FA2000"); sub mk_fa { my ($f) = @_; foreach my $p (@list) { mkdir "/data$p/NRU/$f",0755 or warn "mkdir /data$p/NRU/$f err:$!"; symlink "/data$p/NRU/$f","/usr/local/Titan/NRU/$f" or warn "symlink /data$p/NRU/$f err:$!"; shift @list; last; } } foreach my $fa (@FA) { if (@list > 0 ) { &mk_fa($fa); } else { @list = (3 .. 9); &mk_fa($fa); } }
答复: mkdir in the mounted partiti on,please help me,thanks
but I have uses perl -w。 any other problem ? -邮件原件- 发件人: Dermot [mailto:paik...@googlemail.com] 发送时间: 2009年11月17日 19:53 收件人: beginners@perl.org 主题: Re: mkdir in the mounted partition,please help me,thanks 2009/11/17 gaochong : > #!/usr/bin/perl -w > > > > #Auther:gaochong > > > > use strict; > > > > my @list = (3 .. 9); > > my @FA=("FA0001".."FA2000"); > > sub mk_fa { > >my ($f) = @_; > >foreach my $p (@list) { > >mkdir "/data$p/NRU/$f",0755 or warn "mkdir /data$p/NRU/$f > err:$!"; You should "use warnings". Are you getting a warning from this line? What dies $! say. There should be getting an error message and that will tell you exactly what the problem is. 10/1 says it's file permissions. Dp. -- 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/
答复: 答复: mkdir in the mounted par tition,please help me,thanks
I did not receive err msg . -邮件原件- 发件人: Dermot [mailto:paik...@googlemail.com] 发送时间: 2009年11月17日 20:16 收件人: beginners@perl.org 主题: Re: 答复: mkdir in the mounted partition,please help me,thanks 2009/11/17 gaochong : > but I have uses perl -w。 > any other problem ? Did you receive and error message? Dp. -- 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/
答复: mkdir in the mounted partiti on£¬please help me£¬thanks
> foreach my $fa (@FA) { > if (@list > 0 ) { > &mk_fa($fa); > } else { > @list = (3 .. 9); > &mk_fa($fa); > } Or simply: @list = 3 .. 9 unless @list; mk_fa( $fa ); YES,thanks ! You should *never* modify an array that you are iterating over in a foreach loop. What exactly are you attempting to do here? for example as follows, in /data3 mkdir FA0001 in /data4 mkdir FA0002 in /data8 mkdir FA0010 in /data3 mkdir FA0011 in /data4 mkdir FA0012 in /data8 mkdir FA0016 Do you have better idea ? thank you ! [r...@nru-yz NRU]# df -h 文件系统 容量 已用 可用 已用% 挂载点 /dev/sda2 19G 5.3G 13G 30% / /dev/sda5 120G 2.0G 112G 2% /data /dev/sda6 120G 11G 103G 10% /data2 tmpfs1014M 0 1014M 0% /dev/shm /dev/sdb1 908G 476G 386G 56% /data3 /dev/sdc1 2.0T 1.2T 713G 63% /data4 /dev/sdh1 1.8T 1.3T 438G 75% /data5 /dev/sdg1 1.7T 1.2T 444G 73% /data9 /dev/sde1 1.7T 468G 1.2T 29% /data7 /dev/sdd1 1.7T 639G 1004G 39% /data6 /dev/sdf1 1.7T 1.1T 578G 65% /data8 -邮件原件- 发件人: John W. Krahn [mailto:jwkr...@shaw.ca] 发送时间: 2009年11月18日 14:12 收件人: Perl Beginners 主题: Re: mkdir in the mounted partition£¬please help me£¬thanks gaochong wrote: > #!/usr/bin/perl -w > > #Auther:gaochong > > use strict; > > my @list = (3 .. 9); > my @FA=("FA0001".."FA2000"); > sub mk_fa { > my ($f) = @_; > foreach my $p (@list) { > mkdir "/data$p/NRU/$f",0755 or warn "mkdir /data$p/NRU/$f > err:$!"; > symlink "/data$p/NRU/$f","/usr/local/Titan/NRU/$f" or warn > "symlink /data$p/NRU/$f err:$!"; > shift @list; You should *never* modify an array that you are iterating over in a foreach loop. What exactly are you attempting to do here? > last; > } > } > > foreach my $fa (@FA) { > if (@list > 0 ) { > &mk_fa($fa); > } else { > @list = (3 .. 9); > &mk_fa($fa); > } Or simply: @list = 3 .. 9 unless @list; mk_fa( $fa ); > } 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/
about signal
#!/usr/bin/perl -w use strict; $SIG{INT}=\&stop; $|=1; my $count=3; while ($count) { print "hello\n"; sleep 1; } sub stop { $SIG{INT}=\&stop; -here why set this ? if no ,the result is same . $count--; print "$count\n"; unless ($count){ print "sorry,I did not want to stop ...\n"; } }
答复: mkdir in the mounted partition,pl ease help me,thanks
-邮件原件- 发件人: Chris Charley [mailto:char...@pulsenet.com] 发送时间: 2009年11月19日 5:21 收件人: beginners@perl.org 主题: Re: mkdir in the mounted partition,please help me,thanks - Original Message - From: ""Chris Charley"" Newsgroups: perl.beginners To: Sent: Wednesday, November 18, 2009 12:39 PM Subject: Re: mkdir in the mounted partition,please help me,thanks > > - Original Message - > From: ""gaochong"" > Newsgroups: perl.beginners > To: > Sent: Tuesday, November 17, 2009 6:41 AM > Subject: mkdir in the mounted partition,please help me,thanks [snip some content] > > As to a better way, here is another way (without reconstructing the @list > array). > > #!/usr/bin/perl > use strict; > use warnings; > use File::Path; # uses 'mkpath' to make new included dirs in a path > > my ($i, @p) = (-1, 3 .. 9); > > foreach my $f ("FA0001".."FA2000") { > my $p = $p[++$i % @p]; There is really no need for the @p array. You could calculate $p like: my $p = ++$i % 7 + 3; In this example this can do ,but I have the following partitions and will not finish .so have to using @list and reconstruct it ,and you ? 文件系统 容量 已用 可用 已用% 挂载点 /dev/sda1 29G 4.6G 23G 17% / /dev/sda3 235G 3.7G 219G 2% /data tmpfs 2.0G 0 2.0G 0% /dev/shm /dev/sdb1 1.8T 933G 749G 56% /savedata/data01 /dev/sdc1 1.8T 1.2T 456G 73% /savedata/data02 /dev/sdd1 1.8T 1.1T 576G 66% /savedata/data03 /dev/sde1 1.8T 1.1T 647G 62% /savedata/data04 /dev/sdf1 1.8T 1.2T 551G 68% /savedata/data05 /dev/sdg1 1.2T 442G 707G 39% /savedata/data06 /dev/sdh1 1.8T 699G 984G 42% /savedata/data11 /dev/sdi1 1.8T 940G 743G 56% /savedata/data12 /dev/sdj1 1.8T 962G 720G 58% /savedata/data13 /dev/sdk1 1.8T 937G 746G 56% /savedata/data14 /dev/sdl1 1.8T 1.3T 445G 74% /savedata/data15 /dev/sdm1 1.2T 612G 537G 54% /savedata/data16 /dev/sdn1 1.8T 1.2T 465G 73% /savedata/data21 /dev/sdo1 1.8T 1.2T 458G 73% /savedata/data22 /dev/sdp1 1.8T 874G 808G 52% /savedata/data23 /dev/sdq1 1.8T 1007G 675G 60% /savedata/data24 /dev/sdr1 1.8T 1.4T 320G 81% /savedata/data25 /dev/sds1 1.2T 609G 541G 53% /savedata/data26 /dev/sdt1 1.7T 1.1T 523G 68% /savedata/data31 > #mkpath(["/data$p/NRU/$f"], 0, 0755) unless -e "/data$p/NRU/$f"; > #symlink "/data$p/NRU/$f","/usr/local/Titan/NRU/$f" > # or warn"symlink /data$p/NRU/$f err:$!"; > print "/data$p/NRU/$f\n"; > } > > This example uses the 'mkpath()' function which *will* construct the > entire path (unlike the mkdir() function). mkpath() is included in the > base perl 5.8 distribution, so it may be available to you. YES,mkpath() function of File::Path is a good idea and I will try it . > > Chris -- 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
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() { @array=split(/([A-Z]+(_|[A-Z])+\=.[^A-Z]+)/,$_); thanks
答复: 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/
a perl code to get the process info ,Your comments and suggestions are welcome
hi all I refer to the following page and correct it somewhole , ,Your comments and suggestions are welcome , thanks . http://www.cpan.org/authors/id/S/SU/SUJAI/Process-Detail-0.1.pl the code: #!/usr/bin/perl use warnings; use strict; use Switch; my $VERSION=0.1; my $dir="/proc"; opendir DIR,$dir or die "opendir $dir err:$!"; sub hidden { print "#" x 10 . "Hidden processlist" . "#" x 10 . "\n"; foreach my $pcs (readdir DIR) { if ($pcs=~/\d+/ && $pcs=~/\./) { &detailedview("$pcs"); } } } sub all { foreach my $pcs (readdir DIR) { if ($pcs=~/\d+/) { &detailedview("$pcs"); } } } sub detailedview { my @ar...@_; my $envir="/proc/$args[0]/environ"; my $stat="/proc/$args[0]/status"; open CMD,"/proc/$args[0]/cmdline" or die "open CMD err:$!"; print "PID=$args[0]\n"; while () { print "COMMAND=$_\n"; } open FILE,"< $envir" or die "$!"; while () { my @array=split /([A-Z]+(_|[A-Z])+\=.[^A-Z]+)/,$_; foreach my $splitted (@array) { if ($splitted=~/\=/) { print "$splitted\n"; } } } close FILE; open FILESTAT,"< $stat" or die "$!"; while () { if (/(Name|State|PPid|Gid|Uid)/) { print; } } close FILESTAT; print "-" x 50 . "\n"; } sub usage { print "\nUsage: -h\t For detailed view hidden process -a\t For detailed view of all processes -p\t For detailed view of process with process pid --help\t For help -V\t For checking Version\n\n"; } if ($#ARGV lt 0) { &usage; exit; } else { switch ($ARGV[0]) { case "-h" {&hidden;} case "-p" {&detailedview($ARGV[1]);} case "-a" {&all;} case "--help" {&usage;} case "-V" {print "\nProcess-Detail Version $VERSION\n\n"} else {&usage;} } }
答复: 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/
答复: ìö‘` : the question of o ne program
> -邮件原件- > 发件人: Jim Gibson [mailto:jimsgib...@gmail.com] > 发送时间: 2009年11月20日 15:08 > 收件人: gaochong; 'John W. Krahn'; 'Perl Beginners' > 主题: 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: thanks very much ! > > 1. Don't call subroutines with the '&' character. what's your meaning ? then how to call subroutines ? > 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. with your opinion ,I rewrite one line ,and can be understood easily . if (@ARGV < 1) { &usage; exit; } else { > 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. Nearly ,but I have some question . e.g,how to get the contents of environ line by line ? Now the re is not correct . -- 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=; 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() > > { > > @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/
答复: Regex to get last 3 digits of a number.
substr but you have to set it to be char . can I help you ? > -邮件原件- > 发件人: shadow52 [mailto:ras.collec...@gmail.com] > 发送时间: 2009年11月23日 11:27 > 收件人: beginners@perl.org > 主题: Regex to get last 3 digits of a number. > > Hey everyone, > > I am trying to get just the last 3 numbers from the following number > from perl using regexs but I have not had no success so I was hoping > that I could get a little help on this. I just ordered the regex book > from oreilly so that hopefully in the future I will not have to ask a > question like this again. > > The number is 0111 > > I was just wanting to get the last 3 digits from this number to be > able to get an exact word phrase from my already loaded Hash table > that I have created for various numbers that I will get the last 3 > numbers from. Oh yeah all I was doing was putting this number in a > file and then passing it to perl on the command line incase that is > needed. > > Any help is much appreciated or if you can just point me to a good > place to get a better understanding of how to do this while I wait for > my book to arrive. > > Thanks, > shadow52 > > > -- > 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/
答复: Regex to get last 3 digits of a number.
But I think substr is better . my $str="0111"; my $r=substr ($str,-3); > -邮件原件- > 发件人: John W. Krahn [mailto:jwkr...@shaw.ca] > 发送时间: 2009年11月日 23:23 > 收件人: Perl Beginners > 主题: Re: Regex to get last 3 digits of a number. > > shadow52 wrote: > > Hey everyone, > > Hello, > > > I am trying to get just the last 3 numbers from the following number > > from perl using regexs but I have not had no success so I was hoping > > that I could get a little help on this. I just ordered the regex book > > from oreilly so that hopefully in the future I will not have to ask a > > question like this again. > > > > The number is 0111 > > > > I was just wanting to get the last 3 digits from this number to be > > able to get an exact word phrase from my already loaded Hash table > > that I have created for various numbers that I will get the last 3 > > numbers from. > > To get the last three characters: > > $ perl -le'my $number = "0111"; my ( $last_3 ) = $number =~ > /(...)$/; print $last_3' > 111 > > Or: > > $ perl -le'my $number = "0111"; my $last_3 = substr $number, > -3; print $last_3' > 111 > > Of course the regex version will ignore any newline at the end. > > To get the last three numerical digits only: > > $ perl -le'my $number = "0111"; my ( $last_3 ) = $number =~ > /(\d\d\d)$/; print $last_3' > 111 > > Or: > > $ perl -le'my $number = "0111"; my ( $last_3 ) = $number =~ > /.*(\d\d\d)/; print $last_3' > 111 > > > \d\d\d could also be written as \d{3}. > > > > Oh yeah all I was doing was putting this number in a > > file and then passing it to perl on the command line incase that is > > needed. > > I can not think of why that may be needed? > > > > 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/
答复: reference to anonymous array, refe rences last element instead??
perldoc perlref Making References References can be created in several ways. 1. By using the backslash operator on a variable, subroutine, or value. (This works much like the & (address-of) opera- tor in C.) This typically creates another reference to a variable, because there’s already a reference to the vari- able in the symbol table. But the symbol table reference might go away, and you’ll still have the reference that the backslash returned. Here are some examples: $scalarref = \$foo; $arrayref = \...@argv; $hashref = \%ENV; $coderef = \&handler; $globref = \*foo; It isn’t possible to create a true reference to an IO handle (filehandle or dirhandle) using the backslash operator. The most you can get is a reference to a typeglob, which is actually a complete symbol table entry. But see the explanation of the *foo{THING} syntax below. However, you can still use type globs and globrefs as though they were IO handles. 2. A reference to an anonymous array can be created using square brackets: $arrayref = [1, 2, [’a’, ’b’, ’c’]]; Here we’ve created a reference to an anonymous array of three elements whose final element is itself a reference to another anonymous array of three elements. (The multidimensional syntax described later can be used to access this. For example, after the above, "$arrayref->[2][1]" would have the value "b".) /Taking a reference to an enumerated list is not the same as using square brackets--instead it’s the same as creating a list of references! @list = (\$a, \...@b, \%c); @list = \($a, @b, %c); # same thing! As a special case, "\(@foo)" returns a list of references to the contents of @foo, not a reference to @foo itself. Likewise for %foo, except that the key references are to copies (since the keys are just strings rather than full- fledged scalars). > -邮件原件- > 发件人: Mark_Galeck [mailto:mark_galeck_spam_mag...@yahoo.com] > 发送时间: 2009年11月日 11:53 > 收件人: beginners@perl.org > 主题: reference to anonymous array, references last element instead?? > > Why does > > $foobar = \("foo", "bar"); > print $$foobar; > > > print "bar" ?? > > Thank you for any insight. Mark > > > -- > 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/
答复: Redirecting the output
IO::Tee > -邮件原件- > 发件人: Sooraj S [mailto:soorajspadmanab...@gmail.com] > 发送时间: 2010年11月日 23:14 > 收件人: beginners@perl.org > 主题: Redirecting the output > > Hi, > > Can i redirect the output to a file as well as stdout at the same time...i dont want > to use tee command..i want this to be done in my perl program itself... > > open STDOUT, '>' , 'log.txt''; > > By including this in my perl program i can redirect my output to log.txt. But i want > my output to be displayed on the screen as well.. > > > -- > 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/