in reply to Prorgam obliterates contents of files

You set $^I before the first diamond loop, where you are really only wanting to read the data. Delay that setting until just before the second diamond loop, and all will be well.

I tend to put $^I in a local() setting in the smallest possible scope, just to minimize the potential for damage.

  • Comment on Re: Prorgam obliterates contents of files

Replies are listed 'Best First'.
Re^2: Prorgam obliterates contents of files
by spx2 (Deacon) on Dec 29, 2008 at 09:34 UTC
    so this is what local is used for ? controlling the value of a variable in a particular scope ? what other uses does local have ?

        #2 and #3 were obsoleted by 5.6 back in 2000.

        I wish the Perl guts Data::Alias requires become public. Then #4 would go away too.

Re^2: Prorgam obliterates contents of files
by xhunter (Sexton) on Dec 29, 2008 at 16:33 UTC
    You'll probably want to check whether @ARGV is empty after you've re-created it or that second diamond loop will sit quietly waiting for something when nothing is coming, i.e. the program won't terminate when @ARGV is empty.