Perl Christmas Quiz 2009

Ruud H.G. van Tol rvtol at
Tue Dec 1 07:44:59 GMT 2009

Abigail wrote:
> On Mon, Nov 30, 2009 at 06:24:12PM +0000, Chris Jack wrote:

>> 7) Write a one line program that takes a non-negative integer as an argument
>> and prints the square root when the answer's an integer.
>> Restrictions: the perl line should be a regular expression.
> Just a regular expression? Regular expressions don't print, so that would
> be impossible.

Though perl can print itself:

   echo 169 | perl -ple'$_="the square root"if/^\d+$/'

(this is not an answer)


More information about the mailing list