in reply to Re^2: update values in one file from another
in thread update values in one file from another

If I wanted to change the logic of the above code so all values not in $fed{1} were incremented by 1 instead , how would I do this ?
I tried doing this
local @ARGV = ('file1.txt'); local $^I = '.bak'; while (<>) { m/^(\w+)\s+(\d+)$/; printf "$1\t%d\n", not exists $fed{$1} ? $2+1 : 0; }
This only works the first time it's run, after that everything that isn't in $fed{1} is always only set to 1. I was trying to get it to increment all other values by 1 each time and set the $fed{1} values to 0
I think my logic is screwed up somewhere ?

Replies are listed 'Best First'.
Re^4: update values in one file from another
by Anonymous Monk on Dec 08, 2005 at 10:39 UTC
    My mistake, I realised how to solve it
    local @ARGV = ('file1.txt'); local $^I = '.bak'; while (<>) { m/^(\w+)\s+(\d+)$/; printf "$1\t%d\n", exists $fed{$1} ? 0 : $2+1; }