Главная страница
Top.Mail.Ru    Яндекс.Метрика
Текущий архив: 2002.02.04;
Скачать: CL | DM;

Вниз

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

 
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;
Скачать: CL | DM;

Наверх




Память: 0.47 MB
Время: 0.01 c
3-8756
alive
2002-01-04 17:26
2002.02.04
Долго происходит вызов информации по lookup .


1-8817
DJ X
2002-01-19 15:52
2002.02.04
Web браузер


1-8883
Deutschmann
2002-01-16 12:04
2002.02.04
Масштабирование щрифтов


1-8914
Ser
2002-01-15 03:19
2002.02.04
Delphi


1-8870
NY152
2002-01-15 09:59
2002.02.04
Подскажите, где поставить проверку...