Gossamer Forum
Home : General : Perl Programming :

A quick quiz....

Quote Reply
A quick quiz....
Ok here's a little quiz.

$_='000(*&£$^IYGFSD000*&£$YV£*Q£J$^$£"0000£("*&$^';

I want to see if anyone can print (000) 000-0000 (US phone number) using $_ above and get the code to die if there are not 3 groups of digits (000 000 0000) in under 48 characters of perl code including spaces.

Last edited by:

RedRum: Feb 12, 2002, 6:41 AM
Quote Reply
Re: [RedRum] A quick quiz.... In reply to
print "(000) 000-0000";

So on what mailing list/newgroup did you see this one, then?

- wil
Quote Reply
Re: [Wil] A quick quiz.... In reply to
>>print "(000) 000-0000";<<

That's your answer?

Note : using $_

Last edited by:

RedRum: Feb 12, 2002, 7:24 AM
Quote Reply
Re: [RedRum] A quick quiz.... In reply to
No, that was my sarcastic answer.

My real answer was; why do you want to know? On what mailing list or newsgroup have you seen this? And, shouldn't you be at College or something? ;-)

- wil
Quote Reply
Re: [RedRum] A quick quiz.... In reply to
I forgot to point out I did it in 48 characters including spaces.

split/\D+/;@_==3?print"($_[0]) $_[1]-$[2]":die;

Last edited by:

RedRum: Feb 12, 2002, 7:35 AM
Quote Reply
Re: [RedRum] A quick quiz.... In reply to
Yeah, that's my point -- why?

- wil
Quote Reply
Re: [RedRum] A quick quiz.... In reply to
Doh.

Theres a flaw in my code as if $_ begins with something other than the area code @_ == 4 so it dies.

Also it wouldn't work if $_ was 0000000000

Back to the drawing board.

Last edited by:

RedRum: Feb 12, 2002, 10:29 AM