22.08.2010 16:49, Alex Emergy пишет: > $ echo o-o |perl -pe 'my $res; while ($_ =~ /([A-Za-z0-9]+)/g) { $res .= > $1; };print $res;' > ooo-o > $
> Почему на выходе 'o-o'? Как сделать, чтобы я получал только содержимое $res? Потому что -p. -p causes Perl to assume the following loop around your program, which makes it iterate over filename arguments somewhat like sed: LINE: while (<>) { ... # your program goes here } continue { print or die "-p destination: $!\n"; } Вот оно и печатает в конце содержимое $_ Попробуйте так: echo o-o | perl -pe 'my $res; while (/([A-Za-z0-9\n]+)/g) { $res .= $1; }; $_ = $res;' -- ubuntu-ru mailing list ubuntu-ru@lists.ubuntu.com https://lists.ubuntu.com/mailman/listinfo/ubuntu-ru