in reply to Re: Editing files...please help
in thread Editing files...please help
Note: you'll do this once, then you need to write your update code along the lines of:use strict ; use DB_File ; use vars qw( %h $k $v ) ; # hash, key value tie %h, "DB_File", "memberpoints", O_RDWR|O_CREAT, 0640, $DB_HASH or die "Cannot open file 'memberpoints': $!\n"; # Load in the whole file data file into the hash/dbm open (FILE, "memberpoints.txt") or die "Can't read: $!"; while (<FILE>) { next unless /-/; chomp; my ($name, $number) = split "-"; $h {$name} = $number; } # print the contents of the hash/dbm while (($k, $v) = each %h) { print "$k -> $v\n" } untie %h ;
Very rough but its cold here and my fingers are getting too stiff to type.use strict ; use DB_File ; use vars qw( %h $k $v ) ; # hash, key value tie %h, "DB_File", "memberpoints", O_RDWR|O_CREAT, 0640, $DB_HASH or die "Cannot open file 'memberpoints': $!\n"; # update $h{vegeta} += 6; # print the contents of the db (debuggin) while (($k, $v) = each %h) { print "$k -> $v\n" } untie %h ;
Update: Fruit? it really was cutnpaste ...
a
|
|---|