Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
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 browsing the Monastery: (6)
As of 2015-07-04 17:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (60 votes), past polls