in reply to delimiters anyone??
When the dbase gets large, the overhead may become problematic. Consider a RDBM like postgres or a good DB like BerkeleyDB.#!/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; } }
Cheers,
Jeroen
"We are not alone"(FZ)
|
|---|