Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Hello World!

by clairudjinn (Beadle)
on Mar 15, 2003 at 00:35 UTC ( [id://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. :)

Replies are listed 'Best First'.
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 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 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 amrangaye (Friar) 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
Domain Nodelet?
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?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (4)
As of 2024-04-19 07:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found