[kw-pm] Last night's meeting
John Macdonald
john at perlwolf.com
Fri Jun 19 09:34:46 PDT 2009
On Fri, Jun 19, 2009 at 12:04:07PM -0400, Raymond wrote:
> 2009/6/19 Max <max at alleged.net>:
> > John Macdonald wrote:
> >>
> >> On Fri, Jun 19, 2009 at 11:39:38AM -0400, John Macdonald wrote:
> >>
> >>>
> >>> On Fri, Jun 19, 2009 at 11:29:20AM -0400, John Macdonald wrote:
> >>>
> >>> $ perl -e 'rand$.<1?$a=$_:1for<>;print$a' <alpha.html
> >>>
> >>> which is 29 chars.
> >>>
> >>
> >> And to fill out my original argument against "cheating", if the
> >> size of command line switches other than -e is not counted in
> >> the rating system, then the solution:
> >>
> >> $ perl -M'-warnings;rand$.<1?$a=$_:1for<>;print$a' -e '' <alpha.html
> >>
> >> is a solution with 0 chars.
> >>
> >
> > I think the idea is that perl -e is free, anything else is counted. (n, p,
> > -M, etc.)
> Grrr... replying to list. I wish gmail had that option.
>
> Any of these are free.
>
> perl -e ''
> perl foo.pl
> foo.pl
>
> In the case of the last the shebang line (but NOT its arguments) is
> free. In general its also played no-modules except for any that are
> implicitly loaded by core perl commands. Extra symbols given by
> implicit loads aren't allowed without actually loading the module
> explicitly. All sourced files are considered in the count except IO as
> indicated in the challenge.
>
> That's the generally accepted rules in brief I think.
OK, the remaining "cheating" technique gives a count of 6 chars, as
long as the only things counted are the contents of the script file
and any useful command line args.
$ FILE='rand$.<1?$a=$_:1while<>;print$a'
$ print -n 'eval"$0"' >$FILE
$ perl $FILE <alpha.html
$ wc -c $FILE
6 rand$.<1?$a=$_:1while<>;print$a
Note: I just noticed that using 'for<>' had a bug - it reads all of
the lines before processing the modified statement the first time,
so $. is already incremented to the number of lines in the entire
input and it does not give a fair selection (and can give no selection
at all).
That adds 2 chars to my "no assistance" count.
More information about the kw-pm
mailing list