And here's a from the docs (perldoc db_file) hack to read-in your text and create a dbm:
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 ;
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"; # update $h{vegeta} += 6; # print the contents of the db (debuggin) 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.

Update: Fruit? it really was cutnpaste ...

a


In reply to Re: Re: Editing files...please help by a
in thread Editing files...please help by tanger

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.