Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: delimiters anyone??

by jeroenes (Priest)
on Jun 18, 2001 at 10:25 UTC ( [id://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)

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (4)
As of 2024-04-23 23:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found