Главная страница
    Top.Mail.Ru    Яндекс.Метрика
Форум: "Потрепаться";
Текущий архив: 2002.02.04;
Скачать: [xml.tar.bz2];

Вниз

Вопрос по Перлу   Найти похожие ветки 

 
anod   (2001-12-12 19:42) [0]

Помогите,
как добавлять текст в начало файла.


 
Дмитрий   (2001-12-13 12:43) [1]

open(<IN>, "a.txt");
my @in = (<IN>);
my @ar = (
"First row",
"Second row"
);
my $str = "Third row";
unshift(@in, $str);
unshift(@in, @ar); #unshift(@in, $str, @ar);
open(<IN>, ">a.txt");
print IN @in;
close(IN);


 
anod   (2001-12-13 19:59) [2]

2 Дмитрий
Спасибо, а что такое unshift


 
Kapusto   (2001-12-14 09:36) [3]

shift наоборот :)

unshift ARRAY,LIST
Does the opposite of a shift. Or the opposite of a push, depending on how you look at it. Prepends list to the front of the array, and returns the new number of elements in the array.

unshift(ARGV, "-e") unless $ARGV[0] =~ /^-/;

Note the LIST is prepended whole, not one element at a time, so the prepended elements stay in the same order. Use reverse to do the reverse.


btw, должно быть
open(IN, "a.txt");



Страницы: 1 вся ветка

Форум: "Потрепаться";
Текущий архив: 2002.02.04;
Скачать: [xml.tar.bz2];

Наверх





Память: 0.44 MB
Время: 0.004 c
14-8985
perov
2001-12-14 06:04
2002.02.04
С праздником!!!!!!


1-8859
kaif
2002-01-21 03:56
2002.02.04
MDI и WindowMenu ???


7-9005
AlikRyazan
2001-10-25 18:12
2002.02.04
Модем


3-8782
Pete
2002-01-03 09:57
2002.02.04
InterBase


1-8951
Oleg Fomicheff
2002-01-18 13:18
2002.02.04
RxLib TrayIcon: как убрать из Taskbar





Afrikaans Albanian Arabic Armenian Azerbaijani Basque Belarusian Bulgarian Catalan Chinese (Simplified) Chinese (Traditional) Croatian Czech Danish Dutch English Estonian Filipino Finnish French
Galician Georgian German Greek Haitian Creole Hebrew Hindi Hungarian Icelandic Indonesian Irish Italian Japanese Korean Latvian Lithuanian Macedonian Malay Maltese Norwegian
Persian Polish Portuguese Romanian Russian Serbian Slovak Slovenian Spanish Swahili Swedish Thai Turkish Ukrainian Urdu Vietnamese Welsh Yiddish Bengali Bosnian
Cebuano Esperanto Gujarati Hausa Hmong Igbo Javanese Kannada Khmer Lao Latin Maori Marathi Mongolian Nepali Punjabi Somali Tamil Telugu Yoruba
Zulu
Английский Французский Немецкий Итальянский Португальский Русский Испанский