Chinaunix首页 | 论坛 | 博客
  • 博客访问: 837970
  • 博文数量: 253
  • 博客积分: 6891
  • 博客等级: 准将
  • 技术积分: 2502
  • 用 户 组: 普通用户
  • 注册时间: 2010-11-03 11:01
文章分类

全部博文(253)

文章存档

2016年(4)

2013年(3)

2012年(32)

2011年(184)

2010年(30)

分类: Python/Ruby

2011-10-18 11:27:01

use `` to get the output of the command. use chomp to delete the new line of the output.
  1. chomp(my $no_newline_now = `date`);
  2. print "A moment ago, it was $no_newline_now, I think.\n";

  1. my @functions = qw /int rand sleep length hex eof not exit sqrt umask/;
  2. my %re;

  3. foreach (@functions){
  4.     $re{$_} = `perldoc -t -f $_`;
  5. }

  6. foreach my $key (keys %re){
  7.     print $re{$key};
  8. }
my $who_text = `who`;
the outputs are now in one string, include some newlines.
my @who_list = `who`;
the every line is the element of array who_list. every element includes a newline.



阅读(514) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~