Re: getting perl and php to talk to each other

Discussion in 'Perl Misc' started by Thomas 'PointedEars' Lahn, Mar 5, 2013.

  1. [X-Post & F'up2 comp.lang.php; please do not X-Post without F'up2]

    Ben Morrow wrote:

    > Quoth Cal Dershowitz <>:
    >> [x-posted to clp.misc]

    > [...]
    >>
    >> This article has me convinced that I want perl and php able to deal with
    >> each other:
    >>
    >> http://www.linuxjournal.com/article/9282?page=0,1

    >
    > Why on Earth would you want to do that? Seriously, I can't think of any
    > situation where mixing PHP and Perl is easier than just writing in Perl
    > in the first place.


    Other people would say the same about writing PHP instead of a mix.

    However, there can be value in two programming languages in the same
    program. Just consider what kinds of data you can pass via the command
    line and what kinds you cannot pass that way (yes, there are text files,
    named pipes, and other equally ugly workarounds).

    > Note that the Perl in that article (or at least, the first page, which
    > was all I read) is pretty bad:
    >
    > […]
    > - using PHP to talk to a database, when Perl's DBI module is
    > considerably better than PHP's rather random database functions.
    >
    > I don't know PHP well enough to comment on it,


    Yet you did, which shows that you have never used PHP Data Objects (PDO).
    “*Random* database functions� IBTD.

    > but I wouldn't be surprised if the PHP code was just as bad (for instance,
    > I understand PHP has a saner database interface these days; I don't know
    > if it existed in 2007, though).


    It did; for example, “PDO [shipped] with PHP 5.1â€, “[r]eleased: 24 Nov
    2005â€, which is not that hard to find out:

    <http://www.php.net/manual/en/intro.pdo.php>
    <http://www.php.net/releases/>


    PointedEars
    --
    Prototype.js was written by people who don't know javascript for people
    who don't know javascript. People who don't know javascript are not
    the best source of advice on designing systems that use javascript.
    -- Richard Cornford, cljs, <f806at$ail$1$>
    Thomas 'PointedEars' Lahn, Mar 5, 2013
    #1
    1. Advertising

  2. On 3/5/2013 6:59 PM, Ben Morrow wrote:
    >
    > Quoth Thomas 'PointedEars' Lahn <>:
    >> [X-Post & F'up2 comp.lang.php; please do not X-Post without F'up2]

    >
    > OK. As such I won't see any replies.
    >


    Don't worry about Pointed Head. He's a well known troll in several
    newsgroups.

    <snip>

    >>> Why on Earth would you want to do that? Seriously, I can't think of any
    >>> situation where mixing PHP and Perl is easier than just writing in Perl
    >>> in the first place.

    >>
    >> Other people would say the same about writing PHP instead of a mix.

    >
    > Yes, of course.
    >


    A long shot - maybe you have a package in one language you need to feed
    input to. But that input must first be processed by a package in the
    other language. Rather than rewrite everything, merge them together.

    Or, perhaps you need to build the data preprocessor, and aren't familiar
    with the language the package is written in.

    I agree it would be quite rare, but it's about the only reason I could
    think of people would need both languages. I'm sure there are more, though.

    >> However, there can be value in two programming languages in the same
    >> program. Just consider what kinds of data you can pass via the command
    >> line and what kinds you cannot pass that way (yes, there are text files,
    >> named pipes, and other equally ugly workarounds).

    >
    > The methods used by PHP::Interpreter are not really any less ugly. Until
    > you get to the point of being able to run the two languages on the same
    > VM with properly interworking data structures (such as Parrot is trying
    > to achieve, for instance) I don't see much point stuffing the two
    > languages into the same process and then just passing strings to eval
    > back and forth.
    >


    I doubt that they'll ever have internetworking data structures, though.
    Just not a need for it.

    >>> Note that the Perl in that article (or at least, the first page, which
    >>> was all I read) is pretty bad:
    >>>
    >>> […]
    >>> - using PHP to talk to a database, when Perl's DBI module is
    >>> considerably better than PHP's rather random database functions.
    >>>
    >>> I don't know PHP well enough to comment on it,

    >>
    >> Yet you did, which shows that you have never used PHP Data Objects (PDO).
    >> “*Random* database functions� IBTD.

    >
    > I have not. The database functions used in the article referenced were
    > mssql_connect and so on, which last time I used PHP (a long time ago)
    > was all there was. I don't think you can deny that *those* functions
    > (and the equivalent set for other databases) are a nasty mess. I tried
    > to make it clear that I understand the state of the PHP art has improved
    > since then.
    >
    > My major point was that I don't see any good reason to call into PHP
    > just to connect to a database, when Perl already has perfectly good
    > database code. Had the example been written the other way around the
    > equivalent point could of course have been made about calling into Perl.
    >


    I agree with both of your points. Both languages have reasonable means
    of accessing data. I don't think there are any databases one language
    can access but not the other.

    However, I wouldn't call those functions a "nasty mess". But then I was
    writing C code > 25 years ago, and these are just wrappers around C
    functions. And while there are other ways such as PDO, they also
    typically add an extra layer of overhead. In a busy system, this may or
    may not be important. However, if the system is that busy, I wouldn't
    be switching back and forth between languages, either.


    >>> but I wouldn't be surprised if the PHP code was just as bad (for instance,
    >>> I understand PHP has a saner database interface these days; I don't know
    >>> if it existed in 2007, though).

    >>
    >> It did; for example, “PDO [shipped] with PHP 5.1â€, “[r]eleased: 24 Nov
    >> 2005â€, which is not that hard to find out:

    >
    > Not that hard had I been interested, which I'm not, and had I known
    > 'PDO' was the term to look for, which I didn't. (I was actually thinking
    > of the PEAR DB module, which I've observed is a thing that exists.
    > Again, I've no idea if this is the currently-recommended database
    > interface, or how it compares with the Perl DBI.)
    >
    > Ben
    >


    I wouldn't have bothered looking up when a Perl module was shipped, either.

    BTW - comp.lang.perl.misc added back since this is about both languages.

    --
    ==================
    Remove the "x" from my email address
    Jerry Stuckle
    JDS Computer Training Corp.

    ==================
    Jerry Stuckle, Mar 6, 2013
    #2
    1. Advertising

  3. On 3/7/2013 1:37 AM, Cal Dershowitz wrote:
    > On 03/05/2013 05:08 PM, Jerry Stuckle wrote:
    >> On 3/5/2013 6:59 PM, Ben Morrow wrote:

    >

    <snip>

    > What I wanted to do that this article had mentioned was to be able to
    > call perl reliably either from php or from a bash script that
    > comprehends it all.


    To what purpose?

    <snip>

    > I've chosen this rather arbitrary task just to see what I can do with
    > this syntax which is new to me, php, as opposed to what a person can do
    > with, perl, which I have previously used to give me a webpage.


    To what purpose?

    >>
    >> I agree it would be quite rare, but it's about the only reason I could
    >> think of people would need both languages. I'm sure there are more,
    >> though.

    >
    > Can I use perl regex's or do I have to learn a whole 'nother idea of
    > what that is?


    If you're writing in PHP, you learn PHP's way of doing things. It also
    has regex's (which are pretty close to Perl's).

    <snip>

    > I'm not thrilled with being OT again, but I just can't get
    > PHP::Interpreter to install and don't know exactly why. I don't like to
    > be OT, but something that seems to work for others isn't for me now, and
    > it's not at the level of scripting languages.
    >


    Most people don't try to mix languages like you are. It overly
    complicates things.

    > I can ask very-flawed specific questions but need to wonder aloud why
    > php-config doesn't work, why files that are supposed to be there aren't,
    > and how I troubleshoot the basic function of it before I actually get
    > this topic off the ground.
    >
    > What exactly do I have to do at this point to get a php-config that
    > works as far as PHP::Interpreter is concerned?
    >
    > I've tried ten things that don't work.


    So, how did you install PHP?

    --
    ==================
    Remove the "x" from my email address
    Jerry Stuckle
    JDS Computer Training Corp.

    ==================
    Jerry Stuckle, Mar 7, 2013
    #3
  4. On 3/7/2013 3:52 AM, Cal Dershowitz wrote:
    > On 03/06/2013 10:57 PM, Ben Morrow wrote:
    >>
    >> Quoth Cal Dershowitz <>:
    >>>
    >>> I've chosen this rather arbitrary task just to see what I can do with
    >>> this syntax which is new to me, php, as opposed to what a person can do
    >>> with, perl, which I have previously used to give me a webpage.

    >>
    >> Cal, please, try to learn one language properly before wildly
    >> introducing more languages to the equation. It *really* isn't going to
    >> help.

    >
    > Help what? Are you certain that it's completely impossible that a file
    > could go missing from me that I would need to do this, and that there
    > would be every reason in this fascist world world to keep me from
    > getting a decent web capability?
    >


    There are hundreds of millions of web sites which have "decent web
    capabilities" but don't try to mix languages. I agree with Ben - learn
    one language first.

    And if you want help, I *highly* suggest you change your attitude.
    Calling people facists does not endear ANYONE.

    > I don't seem to be loading up facebook.ben.pl very often.
    >>
    >>> What exactly do I have to do at this point to get a php-config that
    >>> works as far as PHP::Interpreter is concerned?

    >>
    >> I have already answered that question.
    >>
    >> Ben
    >>

    >
    > Can I bother you to repeat it?


    Can you bother to go back and read the earlier messages in this thread?

    I've tried to help, but you are *quickly* wearing my patience with your
    attitude.

    --
    ==================
    Remove the "x" from my email address
    Jerry Stuckle
    JDS Computer Training Corp.

    ==================
    Jerry Stuckle, Mar 7, 2013
    #4
  5. On 14/03/13 10:41, Cal Dershowitz wrote:
    > On 03/07/2013 05:17 AM, Jerry Stuckle wrote:
    >> On 3/7/2013 3:52 AM, Cal Dershowitz wrote:
    >>> On 03/06/2013 10:57 PM, Ben Morrow wrote:
    >>>>
    >>>> Quoth Cal Dershowitz <>:
    >>>>>
    >>>>> I've chosen this rather arbitrary task just to see what I can do with
    >>>>> this syntax which is new to me, php, as opposed to what a person
    >>>>> can do
    >>>>> with, perl, which I have previously used to give me a webpage.
    >>>>
    >>>> Cal, please, try to learn one language properly before wildly
    >>>> introducing more languages to the equation. It *really* isn't going to
    >>>> help.
    >>>
    >>> Help what? Are you certain that it's completely impossible that a file
    >>> could go missing from me that I would need to do this, and that there
    >>> would be every reason in this fascist world world to keep me from
    >>> getting a decent web capability?
    >>>

    >>
    >> There are hundreds of millions of web sites which have "decent web
    >> capabilities" but don't try to mix languages. I agree with Ben - learn
    >> one language first.
    >>
    >> And if you want help, I *highly* suggest you change your attitude.
    >> Calling people facists does not endear ANYONE.

    >
    > People like me just fine. **** off.


    For a quiet life, just killfile jerry.

    Unless you are a humble and very ignorant noob, he has nothing to teach
    you. Worse a lot of what he says is plain wrong.



    --
    Ineptocracy

    (in-ep-toc’-ra-cy) – a system of government where the least capable to
    lead are elected by the least capable of producing, and where the
    members of society least likely to sustain themselves or succeed, are
    rewarded with goods and services paid for by the confiscated wealth of a
    diminishing number of producers.
    The Natural Philosopher, Mar 14, 2013
    #5
  6. Cal Dershowitz <> wrote:
    >On 03/07/2013 05:17 AM, Jerry Stuckle wrote:

    [...]
    >>>> Cal, please, try to learn one language properly before wildly
    >>>> introducing more languages to the equation. It *really* isn't going to
    >>>> help.
    >>>
    >>> Help what? Are you certain that it's completely impossible that a file
    >>> could go missing from me that I would need to do this, and that there
    >>> would be every reason in this fascist world world to keep me from
    >>> getting a decent web capability?
    >>>

    >>
    >> There are hundreds of millions of web sites which have "decent web
    >> capabilities" but don't try to mix languages. I agree with Ben - learn
    >> one language first.
    >>
    >> And if you want help, I *highly* suggest you change your attitude.
    >> Calling people facists does not endear ANYONE.

    >
    >People like me just fine. **** off.


    Your wish is my command: ***PLONK***

    jue
    Jürgen Exner, Mar 14, 2013
    #6
  7. On 3/14/2013 7:14 AM, The Natural Philosopher wrote:
    > On 14/03/13 10:41, Cal Dershowitz wrote:
    >> On 03/07/2013 05:17 AM, Jerry Stuckle wrote:
    >>> On 3/7/2013 3:52 AM, Cal Dershowitz wrote:
    >>>> On 03/06/2013 10:57 PM, Ben Morrow wrote:
    >>>>>
    >>>>> Quoth Cal Dershowitz <>:
    >>>>>>
    >>>>>> I've chosen this rather arbitrary task just to see what I can do with
    >>>>>> this syntax which is new to me, php, as opposed to what a person
    >>>>>> can do
    >>>>>> with, perl, which I have previously used to give me a webpage.
    >>>>>
    >>>>> Cal, please, try to learn one language properly before wildly
    >>>>> introducing more languages to the equation. It *really* isn't going to
    >>>>> help.
    >>>>
    >>>> Help what? Are you certain that it's completely impossible that a file
    >>>> could go missing from me that I would need to do this, and that there
    >>>> would be every reason in this fascist world world to keep me from
    >>>> getting a decent web capability?
    >>>>
    >>>
    >>> There are hundreds of millions of web sites which have "decent web
    >>> capabilities" but don't try to mix languages. I agree with Ben - learn
    >>> one language first.
    >>>
    >>> And if you want help, I *highly* suggest you change your attitude.
    >>> Calling people facists does not endear ANYONE.

    >>
    >> People like me just fine. **** off.

    >
    > For a quiet life, just killfile jerry.
    >
    > Unless you are a humble and very ignorant noob, he has nothing to teach
    > you. Worse a lot of what he says is plain wrong.
    >
    >
    >


    Ah, yes, the troll has to have his say. We already know you're neither
    the programmer nor the electrical engineer you claim to be. No wonder
    you post under a 'nym. You don't want people to know you're an out of
    work ditch digger who can't figure out which end of the shovel to use.

    If I was as stoopid as you, I'd be ashamed to use my real name, also.

    --
    ==================
    Remove the "x" from my email address
    Jerry Stuckle
    JDS Computer Training Corp.

    ==================
    Jerry Stuckle, Mar 14, 2013
    #7
  8. On 3/14/2013 4:18 AM, Jürgen Exner wrote:
    > Cal Dershowitz <> wrote:
    >> On 03/07/2013 05:17 AM, Jerry Stuckle wrote:

    > [...]
    >>>>> Cal, please, try to learn one language properly before wildly
    >>>>> introducing more languages to the equation. It *really* isn't going to
    >>>>> help.
    >>>>
    >>>> Help what? Are you certain that it's completely impossible that a file
    >>>> could go missing from me that I would need to do this, and that there
    >>>> would be every reason in this fascist world world to keep me from
    >>>> getting a decent web capability?
    >>>>
    >>>
    >>> There are hundreds of millions of web sites which have "decent web
    >>> capabilities" but don't try to mix languages. I agree with Ben - learn
    >>> one language first.
    >>>
    >>> And if you want help, I *highly* suggest you change your attitude.
    >>> Calling people facists does not endear ANYONE.

    >>
    >> People like me just fine. **** off.

    >
    > Your wish is my command: ***PLONK***
    >
    > jue
    >

    Ditto
    Scott Johnson, Mar 14, 2013
    #8
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. mwschenckCRL
    Replies:
    0
    Views:
    315
    mwschenckCRL
    Oct 27, 2006
  2. Rajive Narain
    Replies:
    0
    Views:
    1,582
    Rajive Narain
    Sep 18, 2009
  3. M.L.
    Replies:
    1
    Views:
    80
    Tim Williams
    Jul 17, 2005
  4. M. Strobel
    Replies:
    1
    Views:
    206
    The Natural Philosopher
    Mar 5, 2013
  5. SwissCheese
    Replies:
    2
    Views:
    280
    Thomas 'PointedEars' Lahn
    Mar 18, 2013
Loading...

Share This Page