in reply to editing files with (<>)

The simplest solution would be

$^I = '.bak'; for my $file ( glob 'exa*.txt' ) { @ARGV = $file; while( <> ) { print if $. >= 15; } }

Note that your s/// was superfluous, since if you don't print it, it doesn't end up in the file anyway. And even so, it was inefficient — a simple $_ = ""; would have sufficed.

Makeshifts last the longest.

Replies are listed 'Best First'.
Re^2: editing files with (<>)
by Skeeve (Parson) on Dec 21, 2004 at 09:19 UTC
    $_="" is different from s/.*// because the regexp keeps the line end ("\n" or CR or CRLF or LF)

    $\=~s;s*.*;q^|D9JYJ^^qq^\//\\\///^;ex;print

      I skipped over that since I assumed $_ = "" is what he wanted — he is dropping those lines wholesale after all. I should have noted the fact that it was wrong…

      Makeshifts last the longest.