Вниз
Скачать: 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 вся ветка

Скачать: CL | DM;



Память: 0.44 MB
Время: 0.009 c
3-8778
Сержик
2002-01-04 22:47
2002.02.04
Можно запрос делать сразу из двух баз?


3-8763
Pavel_s
2002-01-03 16:46
2002.02.04
Интеграция Interbase и NT !!!!!!!!!!


1-8940
TAN
2002-01-18 09:57
2002.02.04
как поставить курсор в конец строки


1-8832
Chak
2002-01-18 14:52
2002.02.04
Добавление, удаление файлов в директории


7-9008
Vitaliy Jungle
2001-10-13 05:42
2002.02.04
Гребаный MSDOS




   Наверх