Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
#!/usr/bin/perl -wT use CGI qw(:standard); $ItemForm = param('item'); $AmountForm = param('amount'); $OldLine = `grep $ItemForm stock.dat`; ($item, $OldHeld, $order)=split(/” “/, $OldLine); $NewHeld = $OldHeld-$AmountForm; $NewLine= join (" ",$item, $NewHeld, $order); open(STOCK,"items.dat"); @items=<STOCK>; close STOCK; for ($i=0; $i < $#items; $i++) { $items[ $i ] = $NewLine if ($items[ $i ] eq $OldLine); } open (STOCK,">items.dat"); foreach (@items) { print STOCK; } close(STOCK);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Read/Write ASCII file
by Corion (Patriarch) on Jun 07, 2003 at 12:08 UTC | |
|
(jeffa) Re: Read/Write ASCII file
by jeffa (Bishop) on Jun 07, 2003 at 18:23 UTC | |
|
Security problem in your code ...
by skx (Parson) on Jun 07, 2003 at 22:28 UTC | |
by Anonymous Monk on Jun 08, 2003 at 00:00 UTC | |
by skx (Parson) on Jun 08, 2003 at 13:26 UTC |