Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: delimiters anyone??

by jeroenes (Priest)
on Jun 18, 2001 at 10:25 UTC ( #89234=note: print w/ replies, xml ) Need Help??


in reply to delimiters anyone??

Are you sure about the flat-file approach? That way you always have to read/write the whole thing when editing a single item like:

#!/usr/bin/perl -i #first arg is the item_number, second the text-file with replacement #dbase file on STDIN, edited file on STDOUT my $item_number = $ARGV[0]; open IN, $ARGV[1] or die "Could not open $ARGV[1]: $!"; my $replacement; { local $/ = undef; $replacement = <IN>; } { local $/ = '::'; while( <> ) { $_ = $replacement if $. == $item_number; print; print '::' if not eof; } }
When the dbase gets large, the overhead may become problematic. Consider a RDBM like postgres or a good DB like BerkeleyDB.

Cheers,

Jeroen
"We are not alone"(FZ)


Comment on Re: delimiters anyone??
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://89234]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (10)
As of 2014-09-17 16:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (91 votes), past polls