Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Hello World!

by clairudjinn (Beadle)
on Mar 15, 2003 at 00:35 UTC ( #243219=perlmeditation: print w/ replies, xml ) Need Help??

"Hi everyone,

I was playing with Perl at 2:30 this morning. My play turned to "Hello World!"...this is what came out:

sub getName { (shift)->{name} } print "Hello ", bless({name => "World!\n"})->getName;

It's object-based, doesn't use any explicit variables, and runs under strict and warnings pragmas.

I thought I would put this out to you all as an opportunity to creatively breathe new life into "Hello World!". I'd love to see what people came up with. If it turns out to be a fun and interesting thread, I'll post this on PerlMonks."

~Although this is a meditation, it's also an invitation, even a request, for people to post their wacky version of "Hello World!"...the Victoria-PM was very prompt with some doozies. :)

Comment on Hello World!
Download Code
Re: Hello World!
by pg (Canon) on Mar 15, 2003 at 18:56 UTC
    use threads; use threads::shared; use strict; use warnings; my $hellos_turn : shared = 1; $| ++; threads->create(sub { while (1) { sleep(1) until ($hellos_turn); print "Hello "; $hellos_turn = 0; threads->yield; } }); threads->create(sub { while (1) { sleep(1) while ($hellos_turn); print "World!\n"; $hellos_turn = 1; threads->yield; } }); <STDIN>;
Re: Hello World!
by Abigail-II (Bishop) on Mar 15, 2003 at 23:02 UTC
    How's this different from the 'Just another Perl Hacker' programs (except that it prints a different text) that have been floating around in the Perl community for eons?

    You might want to take a look at the file 't/japh/abigail.t' in the Perl distribution. Just substitute the appropriate strings such that it prints 'Hello world' instead of 'Just another Perl Hacker'.

    # Computed goto, self modifying code, a loop with an unconditional # jumps, that terminates anyway, uses strict, warnings and POD, # and fits in a single line less than 80 characters: perl -Mstrict -we '$_ = "goto F.print chop;\n=dlroW olleH";F1:eval'

    Abigail

Re: Hello World!
by Ctrl-z (Friar) on Mar 16, 2003 at 13:25 UTC
    not much of a japh - but suitably odd for a Sunday.
    use LWP::Simple; get('http://perlmonks.org/index.pl?node_id=243219') =~ m|.*<h3 class="other">(.*?)</h3>.*| and print $1;



    time was, I could move my arms like a bird and...

      I prefer to use modules :)

      use LWP::Simple; use XML::Simple; print XMLin(get('http://perlmonks.org/?node_id=37150;nodes=243219'))-> +{NODE}->{content}, "\n";

      Ciao, Valerio

Re: Hello World!
by amrangaye (Pilgrim) on Mar 17, 2003 at 15:09 UTC
    How about this:
    perl -e "print 'world',(print 'hello ')&& undef"
    The && undef part is to stop it displaying "Hello world1", 1 being returned by the second print( 1 && undef will return the empty string '', which will not be displayed).
Re: Hello World!
by Aristotle (Chancellor) on Mar 22, 2003 at 12:55 UTC
    perl -ple'}{package Hello;&world;sub AUTOLOAD{$_=$AUTOLOAD;s;::; ;}' < + /dev/null

    Makeshifts last the longest.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlmeditation [id://243219]
Approved by djantzen
Front-paged by hsmyers
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (10)
As of 2014-08-22 09:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (152 votes), past polls