develooper Front page | perl.fwp | Postings from January 2002

Re: FORE! Get Even Golf Game Tees Off

Thread Previous | Thread Next
From:
Sean McAfee
Date:
January 24, 2002 13:25
Subject:
Re: FORE! Get Even Golf Game Tees Off
Message ID:
200201242124.NAA06077@artemis.transmeta.com
Andrew.Savige@ir.com wrote:
>sub GolfScore {
>   my $script = shift;
>   local ($_, *FF);
>   open(FF, $script) or die "could not open $script: $!";
>   my $golf = -1;     # your free last newline
>   while (<FF>) {
>       s/\n?$/\n/;
>       $golf-- if $. == 1 && s/^#!.*?perl//;

I just realized I was being unfairly penalized by this line because my
hash-bang line looks like this:

#!/some/path/perl5/bin/perl

Might I suggest the following instead?

$golf-- if $. == 1 && s/^#!.*?perl(?!\S)//;

>       $golf += length;
>   }
>   close(FF);
>   return $golf;
>}

-- 
"It's a deicide.  This guy Lokk arranged the murder of this guy Baldur.
 Now Baldur's Dad's going postal and threatening to end the universe..."
"I've had enough of this.  Listen, Pops, you end the universe and I'm
running you BOTH in!" -- from Top Ten #7 | Sean McAfee | mcafee@transmeta.com

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About