use `` to get the output of the command. use chomp to delete the new line of the output.
- chomp(my $no_newline_now = `date`);
-
print "A moment ago, it was $no_newline_now, I think.\n";
- my @functions = qw /int rand sleep length hex eof not exit sqrt umask/;
-
my %re;
-
-
foreach (@functions){
-
$re{$_} = `perldoc -t -f $_`;
-
}
-
-
foreach my $key (keys %re){
-
print $re{$key};
-
}
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.
阅读(546) | 评论(0) | 转发(0) |