+ -
当前位置:首页 → 问答吧 → 兰花仙子来帮我看看在WINDOW下执行,SOLARIS下结果不对

兰花仙子来帮我看看在WINDOW下执行,SOLARIS下结果不对

时间:2010-07-28

来源:互联网

本帖最后由 nokia4321 于 2010-07-28 20:42 编辑

#! /usr/bin/perl
use warnings;
use strict;
my @line1;
open DH,"allog" or die "can not open !\n";
while (my $line=<DH>{
        if($line=~/^\s*?AP/) {
        $line=~s/\n//g;
        }
        push @line1,$line;
}
close (DH);
print @line1;


在WINDOW下的 显示 AP ....然后下一行显示在后边
solaris下显示的是 AP ... 不显示了,直接显示下一行.
为什么呢.

作者: nokia4321   发布时间: 2010-07-28

版本是:
This is perl, v5.6.1 built for sun4-solaris-64int
(with 48 registered patches, see perl -V for more detail)

Copyright 1987-2001, Larry Wall

Perl may be copied only under the terms of either the Artistic License or the
GNU General Public License, which may be found in the Perl 5 source kit.

Complete documentation for Perl, including FAQ lists, should be found on
this system using `man perl' or `perldoc perl'.  If you have access to the
Internet, point your browser at http://www.perl.com/, the Perl Home Page.

作者: nokia4321   发布时间: 2010-07-28

chomp
或者
s/[\n\r]{1,2}//g

作者: ttcn_cu   发布时间: 2010-07-28