Автор Тема: Объясните назначение переменной $/  (Прочитано 3602 раз)

0 Пользователей и 1 Гость просматривают эту тему.

Оффлайн fs444

  • Заглянувший
  • Новичок
  • *
  • Сообщений: 1
  • +0/-0
  • 0
    • Просмотр профиля
    • http://
Объясните назначение переменной $/

Код с ней
@array=("One\\n\\n\\n","Two");
$/=
"";
chomp @array;
print @array;

выводит "OneTwo", а без нее
@array=("One\\n\\n\\n","Two");
chomp @array;
print @array;

выводит
Цитировать
One
   
Two

Как $/=""; влияет на обработку символов новой строки?

Оффлайн ravshaniy

  • Фанат форума
  • Постоялец
  • ***
  • Сообщений: 191
  • +0/-0
  • 0
    • Просмотр профиля
    • http://
Объясните назначение переменной $/
« Ответ #1 : 09 Мая 2009, 16:30:25 »
perldoc -f chomp дает описание


    chomp VARIABLE
    chomp( LIST )
    chomp   This safer version of "chop" removes any trailing string that
            corresponds to the current value of $/ (also known as
            $INPUT_RECORD_SEPARATOR in the "English" module). It returns the
            total number of characters removed from all its arguments. It\'s
            often used to remove the newline from the end of an input record
            when you\'re worried that the final record may be missing its
            newline. When in paragraph mode ("$/ = """), it removes all
            trailing newlines from the string. When in slurp mode ("$/ =
            undef") or fixed-length record mode ($/ is a reference to an
            integer or the like, see perlvar) chomp() won\'t remove anything.
убили кенни, сволочи

 

Sitemap 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28