but the last 6 operators (ie the ones containing a ".") are not something I'm familiar with

Uhm, good question. Can't remember seeing these in the wild before. But when dealing with objects, you nearly always have to write your own operators overloads.


And now for some fun:

Or is it just something that I can use to do whatever I want ?

As with pretty much every other thing involving the perl parser, the answer is a resounding yes. Mostly thanks to XS and source code filters, the perl interpreter is not limited to a single programming language, syntax, basic concept or even probably the somewhat limited charset available in Unicode. Only your imagination is the limit. The following may or may not be stuff that the Perl core devs intended, but which nevertheless is possible:

#!/usr/bin/env perl use Acme::Brainfuck; print "Just another "; ++++++[>++++++++++++++++<-]> ++.-- >+++[<++++++>-]<.>[-]+++[<------>-]< +.- +++++++++.--------- ++++++++++++++.-------------- ++++++.------ >+++[<+++++++>-]<.>[-]+++[<------->-]< +++.--- +++++++++++.----------- print " hacker.\n";

use JavaScript::Embedded; ## create new js context my $js = JavaScript::Embedded->new(); # set function to be used from javascript land $js->set('write' => sub { print $_[0], "\n"; }); $js->eval(qq{ (function(){ for (var i = 0; i < 100; i++){ write(i); } })(); });

use Lingua::Shakespeare; The Infamous Hello World Program. Romeo, a young man with a remarkable patience. Juliet, a likewise young woman of remarkable grace. Ophelia, a remarkable woman much in dispute with Hamlet. Hamlet, the flatterer of Andersen Insulting A/S. Act I: Hamlet's insults and flattery. Scene I: The insulting of Romeo. [Enter Hamlet and Romeo] Hamlet: You lying stupid fatherless big smelly half-witted coward! You are as stupid as the difference between a handsome rich brave hero and thyself! Speak your mind! etc...

use Acme::ButFirst; # Print a greeting, but first find caffiene. { print "Good morning!\n"; } but first { print "I need a coffee\n"; }

use Inline ASM => <<'END', PROTOTYPES => {JAxH => 'void(char*)'}; .globl JAxH .text # prototype: void JAxH(char *x); JAxH: pushl %ebp movl %esp,%ebp movl 8(%ebp),%eax pushl %eax pushl $jaxhstr call printf movl %ebp,%esp popl %ebp ret .data jaxhstr: .string "Just Another %s Hacker\n" END print JAxH('Perl');

And if you want run a hip AI company without actually writing a lot of code(¹), you can just recycle all the open sourced python stuff within Perl to woo your investors...

print "9 + 16 = ", add(9, 16), "\n"; print "9 - 16 = ", subtract(9, 16), "\n"; use Inline Python => <<'END_OF_PYTHON_CODE'; def add(x,y): return x + y def subtract(x,y): return x - y END_OF_PYTHON_CODE


(¹) Writing actual code for a startup and producing value for the investors is just a waste of money. Money that could be much better spent on Booze, Babes and epic music festivals in the Bahamas featuring the latest in Instagram models...


In reply to Re: Puzzled by value of $overload::ops{binary} by cavac
in thread Puzzled by value of $overload::ops{binary} by syphilis

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.