
Sunchey
Novice
Nov 29, 2012, 5:05 AM
Post #1 of 7
(4000 views)
|
Hello. Don't understand work of script.
#!/usr/bin/perl -w use strict; use diagnostics; if (!open FILE, "+<file.txt") { die "Error: $!\n" } # open file for read/write #$^I = ".bak"; while (<FILE>) #while reading strings from file { s/^\t//g; # erase tabs at the beginning of file , s/^\s//g do the same print FILE; # print write to STDOUT } close FILE; Script working: 1) tabs has been erased but some symbols had been erased too (And random number of character, why?) 2) all string duplicated. Why? If I commented "print FILE;" string, file has not change but just s/// must change file, isn't it?. File has text type, within string has bytes: 0x0A, 0x0D, sometimes 0x09. Encoding windows 1251. Thank you.
|