Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask

Polymorphism JAPH

by cristian (Hermit)
on Apr 13, 2005 at 17:23 UTC ( #447517=obfuscated: print w/replies, xml ) Need Help??

Concept : Educational OO Polymorphism practice with Japh
#!/usr/bin/perl package J ;sub new{$__=shift and(%__)=@_ and bless{1, $__{1}, },$__} package main; #Polymorphism J A P H package A ;sub new{$__=shift and (%__)= @_ and($___)= J->new( @_)and$___->{2}=$__{2}and bless($___,$__);} package P ;sub new{$__=shift and (%__)= @_ and($___)= A->new( @_)and$___->{3}=$__{3}and bless($___,$__);} package H ;sub new{$__=shift and (%__)= @_ and($___)= P->new( @_)and$___->{4}=$__{4}and bless($___,$__);} $o=H->new (1,Just,2,Another,3,Perl,4,Hacker); print "$o->{ $_} " foreach sort keys %{ $o } ;# Educational Concept

Replies are listed 'Best First'.
Re: Polymorphism JAPH
by jbrugger (Parson) on Apr 14, 2005 at 06:01 UTC
    Nice! works like a charm.
    But to be pickey, like merlyn said before, the proper way to write the origional JAPH = j Just another Perl hacker,
    Note the , and the cases. ;-)
    So with the help i got earlyer of this site i took the liberty of changing your nice script a little:
    o=H->new (1,"\152\165\163\164",2,"\141\156\157\164\150\145\162",3,"\120\145\162\154",4,"\150\141\143\153\145\162\54"); print "$o->{
    (i only break your nice lay-out now :-)

    *update* ok, as cog wrote below.... it is:
    o=H->new(1,"\112\165\163\164",2,"\141\156\157\164\150\145\162",3,"\120 +\145\162\154",4,"\150\141\143\153\145\162\54"); print "$o->{ $_}"

    "We all agree on the necessity of compromise. We just can't agree on when it's necessary to compromise." - Larry Wall.
      the proper way to write the origional JAPH = just another Perl hacker,

      The proper way actually has the "j" uppercased, and doesn't have a trailing space (you don't mention this, by I see the obfu prints it).

      print "Just another Perl hacker,";

      That prints it out the proper way.

      Realy the script search show the polymorphism and inheritance this explained with 4 level of call new sub object. I generate 4 level de inheritance for J A P H , is for the art.It's for what look more nice. The idea es practice OO with JAPH - Just another Perl hacker,

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: obfuscated [id://447517]
Approved by ktross
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (3)
As of 2022-01-25 17:56 GMT
Find Nodes?
    Voting Booth?
    In 2022, my preferred method to securely store passwords is:

    Results (67 votes). Check out past polls.