Beefy Boxes and Bandwidth Generously Provided by pair Networks Bob
Pathologically Eclectic Rubbish Lister
 
PerlMonks

What time is it?

by Velenux (Acolyte)
 | Log in | Create a new user | The Monastery Gates | Super Search | 
 | Seekers of Perl Wisdom | Meditations | PerlMonks Discussion | 
 | Obfuscation | Reviews | Cool Uses For Perl | Perl News | Q&A | Tutorials | 
 | Poetry | Recent Threads | Newest Nodes | Donate | What's New | 

on Mar 22, 2004 at 21:25 UTC ( #338780=obfuscated: print w/ replies, xml ) Need Help??

Result of a few hours hacking and requesting for hints and mathematics to some people.
#!/usr/bin/perl $d=`date +%l:%M`;chomp($d);($h,$m)= split(/:/,$d); $h=0 if $h==12;$h=($h*30)+180; $h-= 360 if $h>360;$m = ($m*6)+180;$m-=360 if $m>360;@o =([' ', ' ',' ', ' ',' ' ,' ',' ' , ' ' , ' ',' ', ' ',' ' ,' ' ,' ','|' ],[' ', ' ', ' ',' ', ' ',' ' ,' ' ,' ',' ' , ' ' , ' ', ' ',' ', ' ','|' ], [ ' ',' ', ' ',' ' ,' ' ,' ',' ' , ' ' , ' ', ' ',' ', ' ',' ' ,' ' ,'|'] ,[ ' ',' ' ,' ', ' ',' ', ' ',' ' ,' ' ,' ',' ' , ' ' , ' ', ' ',' ', '|'] ,[ ' ', ' ',' ', ' ',' ' ,' ' ,' ',' ' , ' ' , ' ', ' ',' ', ' ',' ' ,'|' ], [' ', ' ',' ' ,' ' ,' ',' ' , ' ' , ' ', ' ',' ', ' ',' ' ,' ',' ' ,'|'],[ ' ',' ', ' ',' ' ,' ',' ' ,' ',' ' ,' ',' ' ,' ',' ',' ',' ','|'],[' ',' ',' ',' ',' ',' ',' ' ,' ',' ',' ',' ',' ',' ',' ','|'],[' ',' ',' ',' ' ,' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','|'],[' ' ,' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ' , ' ','|'],[' ',' ',' ',' ',' ',' ',' ',' ',' ',' ', ' ',' ',' ',' ','|'],[' ',' ',' ',' ',' ',' ',' ', ' ',' ',' ',' ',' ',' ',' ','|'],[' ',' ',' ',' ', ' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','|'],[' ', ' ',' ',' ',' ',' ',' ',' ',' ', ' ', ' ',' ',' ', ' ','|'],[' ',' ',' ',' ',' ',' ',' ',' ',' ',' ', ' ',' ',' ',' ','|'],[' ',' ',' ',' ',' ',' ',' ', ' ',' ',' ',' ',' ',' ',' ','|'],[' ',' ',' ',' ', ' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','|']); sub dl {$l=$_[2]; while($l-- > 1){$o[int($_[0]+($l*cos ($_[3])))][int($_[1]+($l*sin($_[3])))]=$_[4];}}sub cc {@c=('|','/','-','\\','|','/','-','\\'); return $c[int((abs($_[0])+22.5)/45)];}dl(7,7,5,-(($h/180) *3.1415),&cc(-$h));dl(7,7,7,-(($m/180)*3.1415),&cc (-$m));sub pm {print "-"x29,"\n"; for($z=0;$z<$#o; $z++){print "@{$o[$z]}\n";}print "="x29,"\n";}&pm; print " ---> $d <--- \n"; # Analog Obfuscated Clock # by Gilberto "Velenux" Ficara, March 2004 # # Thanks to Cyberbrown, Javanx, lu_zero, gmax # and noteof for useful hints, algorithms and # supplying to me the mathematics I lack

Comment on What time is it?
Download Code
Re: What time is it?
by muba (Chaplain) on Mar 22, 2004 at 21:38 UTC
    Unfortunately, it doesn't work on W32, because of the `date ...` part.
      Sorry, but I was not thinking about making it portable ;)
        Velenux,
        I hope you don't mind - this should make it portable:
        #!/usr/bin/perl use POSIX 'strftime'; $d=strftime("%l:%M", localtime);chomp($d);($h,$m)= split(/:/,$d); $h=0 if $h==12;$h=($h*30)+180; $h-= 360 if $h>360;$m = ($m*6)+180;$m-=360 if $m>360;@o =([' ', ' ',' ', ' ',' ' ,' ',' ' , ' ' , ' ',' ', ' ',' ' ,' ' ,' ','|' ],[' ', ' ', ' ',' ', ' ',' ' ,' ' ,' ',' ' , ' ' , ' ', ' ',' ', ' ','|' ], [ ' ',' ', ' ',' ' ,' ' ,' ',' ' , ' ' , ' ', ' ',' ', ' ',' ' ,' ' ,'|'] ,[ ' ',' ' ,' ', ' ',' ', ' ',' ' ,' ' ,' ',' ' , ' ' , ' ', ' ',' ', '|'] ,[ ' ', ' ',' ', ' ',' ' ,' ' ,' ',' ' , ' ' , ' ', ' ',' ', ' ',' ' ,'|' ], [' ', ' ',' ' ,' ' ,' ',' ' , ' ' , ' ', ' ',' ', ' ',' ' ,' ',' ' ,'|'],[ ' ',' ', ' ',' ' ,' ',' ' ,' ',' ' ,' ',' ' ,' ',' ',' ',' ','|'],[' ',' ',' ',' ',' ',' ',' ' ,' ',' ',' ',' ',' ',' ',' ','|'],[' ',' ',' ',' ' ,' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','|'],[' ' ,' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ' , ' ','|'],[' ',' ',' ',' ',' ',' ',' ',' ',' ',' ', ' ',' ',' ',' ','|'],[' ',' ',' ',' ',' ',' ',' ', ' ',' ',' ',' ',' ',' ',' ','|'],[' ',' ',' ',' ', ' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','|'],[' ', ' ',' ',' ',' ',' ',' ',' ',' ', ' ', ' ',' ',' ', ' ','|'],[' ',' ',' ',' ',' ',' ',' ',' ',' ',' ', ' ',' ',' ',' ','|'],[' ',' ',' ',' ',' ',' ',' ', ' ',' ',' ',' ',' ',' ',' ','|'],[' ',' ',' ',' ', ' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','|']); sub dl {$l=$_[2]; while($l-- > 1){$o[int($_[0]+($l*cos ($_[3])))][int($_[1]+($l*sin($_[3])))]=$_[4];}}sub cc {@c=('|','/','-','\\','|','/','-','\\'); return $c[int((abs($_[0])+22.5)/45)];}dl(7,7,5,-(($h/180) *3.1415),&cc(-$h));dl(7,7,7,-(($m/180)*3.1415),&cc (-$m));sub pm {print "-"x29,"\n"; for($z=0;$z<$#o; $z++){print "@{$o[$z]}\n";}print "="x29,"\n";}&pm; print " ---> $d <--- \n"; # Analog Obfuscated Clock # by Gilberto "Velenux" Ficara, March 2004 # # Thanks to Cyberbrown, Javanx, lu_zero, gmax # and noteof for useful hints, algorithms and # supplying to me the mathematics I lack
        Cheers - L~R
Re: What time is it?
by teamster_jr (Curate) on Mar 23, 2004 at 11:50 UTC
    very nice.
    you could also wrap the whole thing in this:
    { # clear the screen print "\ec"; # draw your clock <your code> # wait and redo sleep 1; redo }
    also see these for my obfu'd timepieces - yours looks nicer!
    Alex

    Update: Actually i realised you only draw minutes, so you could sleep 60 - slightly less redrawing
    Also I'm not sure print "\ec" works on everything - so perhaps a nicer way would be to use <check os here>?`clear`:`cls`;

      <check os here>?`clear`:`cls`;

      You need a print for that one, as `clear` actually prints escape sequence, so <check os here>?print`clear`:`cls`.

      Also, I think that just print`cls;clear` should work too, as on windows this gives cls a command-line argument which it probably ignores (or it obeys it and makes the console real shiny clear); on linux the clear should hide whatever error cls prints.

Login:
Password
remember me
What's my password?
Create A New User

Node Status?
node history
Node Type: obfuscated [id://338780]
Approved by kvale
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (14)
GrandFather
atcroft
duff
toma
herveus
MidLifeXis
NodeReaper
Intrepid
muba
ssandv
djp
AndyZaft
Neighbour
im2
As of 2010-09-06 03:28 GMT
Sections?
Seekers of Perl Wisdom
Cool Uses for Perl
Meditations
PerlMonks Discussion
Categorized Q&A
Tutorials
Obfuscated Code
Perl Poetry
Perl News
See About the sections of PerlMonks
Information?
PerlMonks FAQ
Guide to the Monastery
What's New at PerlMonks
Voting/Experience System
Tutorials
Reviews
Library
Perl FAQs
Other Info Sources
Find Nodes?
Nodes You Wrote
Super Search
List Nodes By Users
Newest Nodes
Recently Active Threads
Selected Best Nodes
Best Nodes
Worst Nodes
Saints in our Book
Leftovers?
The St. Larry Wall Shrine
Offering Plate
Awards
Craft
Snippets Section
Code Catacombs
Quests
Editor Requests
Buy PerlMonks Gear
PerlMonks Merchandise
Planet Perl
Perlsphere
Use Perl
Perl.com
Perl 5 Wiki
Perl Jobs
Perl Mongers
Perl Directory
Perl documentation
CPAN
Random Node
Voting Booth?

My favourite poll on PerlMonks is ...

Your first Perl Book - the first one ever
Average number of caffeinated beverages per work day - the poll with the highest participation
My Thoughts on the New Voting/Experience System - the poll with the fewest votes cast
When I grow up, I want to be: - one of the polls with the fewest options
Perl 6 will primarily be: - the first one on Perl6
When I see a poll - one of the many polls about polls
this poll ;-)
yet to come
none - I hate polls. Bah.
some other

Results (95 votes), past polls