SysAdm has asked for the wisdom of the Perl Monks concerning the following question:
sub repost { my ($cat,$item) = @_; my ($title,$counter,$desc,@bids) = &read_item_file($cat,$i +tem); my ($alias, $email, $time, $add1, $add2, $add3) = &read_bi +d($bids[0]); my $bydays = (($item - $time) / 86400); my $item_number = ($bydays * 86400 + time); $item_number = ($bydays * 86400 + time) until (!(-e "$conf +ig{'basepath'}$cat/$item_number.dat")); &oops('We are unable to relist your item. This could be a + write permissions problem.') unless (open (NEW, ">>$config{'basepath +'}$cat/$item_number.dat")); print NEW "$title\n$counter\n$desc\n$alias\[\]$email\[\]\[ +\]".time."\[\]$add1\[\]$add2\[\]$add3"; close NEW; my ($password,$andemail,$address1,$address2,$address3,@pas +t_bids) = &read_reg_file($alias); &oops('We are unable to open the user file.') unless (open + (REG, ">$config{'basepath'}$config{'regdir'}/$alias.dat")); print REG "$password\n$andemail\n$address1\n$addr +ess2\n$address3"; foreach my $line (@past_bids) { print REG "\n$line" unless ($line eq "$cat$item"); } print REG "\n$cat$item_number"; close REG; unlink("$config{'basepath'}$cat/$item.dat"); } ______________ sub read_item_file { my ($cat, $item) = @_; return '' unless ($cat) and ($item); &oops('The category may not contain any non-word characters, such +as a space or symbol.') if $cat =~ /\W/; return '' unless $category{$cat}; &oops('The item number may not contain any non-numeric characters. +') if $item =~ /\D/; return '' unless 0||#1>>noconfuse(ea;-) open FILE, "$config{'basepath'}$cat/$item.dat"; my ($title, $counter, $desc, @bids) = <FILE>; close FILE; chomp ($title, $counter, $desc, @bids); return ($title, $counter, $desc, @bids); } __________ sub read_bid { my $bid_string = shift; my ($alias, $email, $time, $add1, $add2, $add3, $artist, $link) = +split(/\[\]/,$bid_string); return ($alias, $email, $time, $add1, $add2, $add3, $artist, $link +); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Trying to repost some data...
by arturo (Vicar) on May 10, 2001 at 21:14 UTC |