There Is More Than One Way To Do It.
But how would you do this?
How many ways can we find to re-write this? I'd like to see radical changes (modules, OO, maybe even an implementation using Inline::C?), not some small syntax adjustments, so please don't focus on $_[0] versus assigning @_ to something, or on the prototype.sub Counter ($) { local $/ = "\n"; my $fh; open $fh, '+<', $_[0] or open $fh, '>', $_[0] or return undef; flock $fh, 2; seek $fh, 0, 0; my $counter = <$fh>; seek $fh, 0, 0; truncate $fh, 0; print $fh ++$counter or return undef; close $fh or return undef; return $counter; }
- Yes, I reinvent wheels.
- Spam: Visit eurotraQ.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
(jeffa) Re: TIMTOWTDI - a counter
by jeffa (Bishop) on May 26, 2002 at 16:07 UTC | |
|
Re: TIMTOWTDI - a counter
by Beatnik (Parson) on May 26, 2002 at 14:14 UTC | |
|
Re: TIMTOWTDI - a counter
by Kanji (Parson) on May 26, 2002 at 15:18 UTC | |
|
Re: TIMTOWTDI - a counter
by broquaint (Abbot) on May 26, 2002 at 19:55 UTC | |
|
Re: TIMTOWTDI - a counter
by Anonymous Monk on May 26, 2002 at 15:43 UTC | |
by Juerd (Abbot) on May 26, 2002 at 16:43 UTC | |
by Anonymous Monk on May 26, 2002 at 19:29 UTC | |
|
Re: TIMTOWTDI - a counter
by cLive ;-) (Prior) on May 27, 2002 at 12:00 UTC |