Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.php > #8512 > unrolled thread

randomly sorting files in php

Started byCal Dershowitz <cal@example.invalid>
First post2013-02-28 17:49 -0800
Last post2013-03-14 03:39 -0700
Articles 20 on this page of 51 — 15 participants

Back to article view | Back to comp.lang.php


Contents

  randomly sorting files in php Cal Dershowitz <cal@example.invalid> - 2013-02-28 17:49 -0800
    Re: randomly sorting files in php Jerry Stuckle <jstucklex@attglobal.net> - 2013-02-28 23:45 -0500
      Re: randomly sorting files in php Cal Dershowitz <cal@example.invalid> - 2013-02-28 22:23 -0800
        Re: randomly sorting files in php David Robley <me@home.invalid> - 2013-03-01 17:24 +1030
          Re: randomly sorting files in php Cal Dershowitz <cal@example.invalid> - 2013-03-03 18:59 -0800
            getting perl and php to talk to each other,  was Re: randomly sorting files in php Cal Dershowitz <cal@example.invalid> - 2013-03-05 01:19 -0800
              Re: getting perl and php to talk to each other,  was Re: randomly sorting   files in php "M. Strobel" <sorry_no_mail_here@nowhere.dee> - 2013-03-05 19:43 +0100
                Re: getting perl and php to talk to each other,  was Re: randomly sorting   files in php The Natural Philosopher <tnp@invalid.invalid> - 2013-03-05 19:20 +0000
              Re: getting perl and php to talk to each other Ben Morrow <ben@morrow.me.uk> - 2013-03-05 22:06 +0000
                Re: getting perl and php to talk to each other Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-03-06 00:20 +0100
                  Re: getting perl and php to talk to each other Ben Morrow <ben@morrow.me.uk> - 2013-03-05 23:59 +0000
                    Re: getting perl and php to talk to each other The Natural Philosopher <tnp@invalid.invalid> - 2013-03-06 01:01 +0000
                    Re: getting perl and php to talk to each other Jerry Stuckle <jstucklex@attglobal.net> - 2013-03-05 20:08 -0500
                      Re: getting perl and php to talk to each other Cal Dershowitz <cal@example.invalid> - 2013-03-06 22:37 -0800
                        Re: getting perl and php to talk to each other Ben Morrow <ben@morrow.me.uk> - 2013-03-07 06:57 +0000
                          Re: getting perl and php to talk to each other Cal Dershowitz <cal@example.invalid> - 2013-03-07 00:52 -0800
                            Re: getting perl and php to talk to each other Jerry Stuckle <jstucklex@attglobal.net> - 2013-03-07 08:17 -0500
                              Re: getting perl and php to talk to each other Cal Dershowitz <cal@example.invalid> - 2013-03-14 03:41 -0700
                                Re: getting perl and php to talk to each other The Natural Philosopher <tnp@invalid.invalid> - 2013-03-14 11:14 +0000
                                  Re: getting perl and php to talk to each other Jerry Stuckle <jstucklex@attglobal.net> - 2013-03-14 08:06 -0400
                                Re: getting perl and php to talk to each other Jürgen Exner <jurgenex@hotmail.com> - 2013-03-14 04:18 -0700
                                  Re: getting perl and php to talk to each other Scott Johnson <noonehome@chalupasworld.com> - 2013-03-14 05:38 -0700
                            Re: getting perl and php to talk to each other Ben Morrow <ben@morrow.me.uk> - 2013-03-07 14:25 +0000
                        Re: getting perl and php to talk to each other Jerry Stuckle <jstucklex@attglobal.net> - 2013-03-07 08:14 -0500
                    Re: getting perl and php to talk to each other Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-03-06 02:08 +0100
                Re: getting perl and php to talk to each other Cal Dershowitz <cal@example.invalid> - 2013-03-06 22:53 -0800
                  Re: getting perl and php to talk to each other "M. Strobel" <sorry_no_mail_here@nowhere.dee> - 2013-03-07 09:46 +0100
                    Re: getting perl and php to talk to each other David Robley <me@home.invalid> - 2013-03-07 21:43 +1030
                      Re: getting perl and php to talk to each other "Peter H. Coffin" <hellsop@ninehells.com> - 2013-03-07 07:32 -0600
                  Re: getting perl and php to talk to each other SwissCheese <swisscheese@cfl.rr.com> - 2013-03-07 06:28 -0500
                    Re: getting perl and php to talk to each other Ben Morrow <ben@morrow.me.uk> - 2013-03-07 14:33 +0000
                      Re: getting perl and php to talk to each other Cal Dershowitz <cal@example.invalid> - 2013-03-14 02:16 -0700
                    Re: getting perl and php to talk to each other Cal Dershowitz <cal@example.invalid> - 2013-03-14 03:28 -0700
                      Re: getting perl and php to talk to each other SwissCheese <swisscheese@cfl.rr.com> - 2013-03-14 06:51 -0400
                        Re: getting perl and php to talk to each other Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-03-18 12:54 +0100
                          Re: getting perl and php to talk to each other SwissCheese <swisscheese@cfl.rr.com> - 2013-03-18 20:23 -0400
                  Re: getting perl and php to talk to each other alexd <troffasky@hotmail.com> - 2013-03-07 19:09 +0000
                    Re: getting perl and php to talk to each other Henry Law <news@lawshouse.org> - 2013-03-07 20:09 +0000
                      Re: getting perl and php to talk to each other Cal Dershowitz <cal@example.invalid> - 2013-03-14 02:23 -0700
                    Re: getting perl and php to talk to each other The Natural Philosopher <tnp@invalid.invalid> - 2013-03-07 20:43 +0000
                      Re: getting perl and php to talk to each other Alastair Black <abqab.nemo@example.net> - 2013-03-07 14:47 -0700
                        Re: getting perl and php to talk to each other "M. Strobel" <sorry_no_mail_here@nowhere.dee> - 2013-03-07 23:11 +0100
                          Re: getting perl and php to talk to each other Alastair Black <abqab.nemo@example.net> - 2013-03-07 15:50 -0700
                      Re: getting perl and php to talk to each other Jerry Stuckle <jstucklex@attglobal.net> - 2013-03-07 19:45 -0500
                        Re: getting perl and php to talk to each other Cal Dershowitz <cal@example.invalid> - 2013-03-14 02:19 -0700
                          Re: getting perl and php to talk to each other Jerry Stuckle <jstucklex@attglobal.net> - 2013-03-14 07:55 -0400
                      where to put the binaries was Re: getting perl and php to talk to each other Cal Dershowitz <cal@example.invalid> - 2013-03-14 03:11 -0700
                        Re: where to put the binaries was Re: getting perl and php to talk to each other The Natural Philosopher <tnp@invalid.invalid> - 2013-03-14 11:12 +0000
                        Re: where to put the binaries was Re: getting perl and php to talk to each other Jerry Stuckle <jstucklex@attglobal.net> - 2013-03-14 08:04 -0400
    Re: randomly sorting files in php Captain Paralytic <paul_lautman@yahoo.com> - 2013-03-04 02:45 -0800
      Re: randomly sorting files in php Cal Dershowitz <cal@example.invalid> - 2013-03-14 03:39 -0700

Page 1 of 3  [1] 2 3  Next page →


#8512 — randomly sorting files in php

FromCal Dershowitz <cal@example.invalid>
Date2013-02-28 17:49 -0800
Subjectrandomly sorting files in php
Message-ID<spqdnTH2yauTlK3MnZ2dnUVZ_o6dnZ2d@supernews.com>
Hello ng,

I've got a working localhost and a couple php scripts that run so far, 
so I wanted to see what types of things I can do and cannot do.  This is 
by no means clear to me to me now.

What I have is a collection of my own music files that I have put in the 
path of where localhost is looking for things; with my default install, 
that is /var/www.

I wrote a bash script to export the files off my mp3 player, because 
neither my gf nor I who bought these things can figure how to make them 
play randomly.  Yes we have achieved a certain age, where determination 
makes up for a lot.

$ cat music1.sh
#!/bin/bash

set -e
FROM='CCE0-705F'
DIR='music1'
mkdir -p $DIR
cp  $FROM/*.wma $DIR/
cp  $FROM/*.mp3 $DIR/
cd $DIR
ls -l
exit 0
$

So does php have a way to do this that is as simple as it might be in 
perl, for example?
-- 
Cal

[toc] | [next] | [standalone]


#8513

FromJerry Stuckle <jstucklex@attglobal.net>
Date2013-02-28 23:45 -0500
Message-ID<kgpbni$cvd$1@dont-email.me>
In reply to#8512
On 2/28/2013 8:49 PM, Cal Dershowitz wrote:
> Hello ng,
>
> I've got a working localhost and a couple php scripts that run so far,
> so I wanted to see what types of things I can do and cannot do.  This is
> by no means clear to me to me now.
>
> What I have is a collection of my own music files that I have put in the
> path of where localhost is looking for things; with my default install,
> that is /var/www.
>
> I wrote a bash script to export the files off my mp3 player, because
> neither my gf nor I who bought these things can figure how to make them
> play randomly.  Yes we have achieved a certain age, where determination
> makes up for a lot.
>
> $ cat music1.sh
> #!/bin/bash
>
> set -e
> FROM='CCE0-705F'
> DIR='music1'
> mkdir -p $DIR
> cp  $FROM/*.wma $DIR/
> cp  $FROM/*.mp3 $DIR/
> cd $DIR
> ls -l
> exit 0
> $
>
> So does php have a way to do this that is as simple as it might be in
> perl, for example?

Sure, you *can* do it in PHP.  But if you have a working bash script, 
why reinvent the wheel?  Especially since it sounds like you don't know 
much about PHP.

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

[toc] | [prev] | [next] | [standalone]


#8514

FromCal Dershowitz <cal@example.invalid>
Date2013-02-28 22:23 -0800
Message-ID<89adnQ0SD_nv1K3MnZ2dnUVZ_vednZ2d@supernews.com>
In reply to#8513
On 02/28/2013 08:45 PM, Jerry Stuckle wrote:
> On 2/28/2013 8:49 PM, Cal Dershowitz wrote:

>> So does php have a way to do this that is as simple as it might be in
>> perl, for example?
>
> Sure, you *can* do it in PHP.  But if you have a working bash script,
> why reinvent the wheel?  Especially since it sounds like you don't know
> much about PHP.
>

Well, if I can't invoke random behavior, I can't think that I have any 
Thuring-compliant medium.

It's to be taken as a learning-example.  I can accomplish this in every 
syntax I know.  I'd like to accomplish this in one I don't.
-- 
Cal

[toc] | [prev] | [next] | [standalone]


#8515

FromDavid Robley <me@home.invalid>
Date2013-03-01 17:24 +1030
Message-ID<kgpjc0$opg$1@news.albasani.net>
In reply to#8514
Cal Dershowitz wrote:

> On 02/28/2013 08:45 PM, Jerry Stuckle wrote:
>> On 2/28/2013 8:49 PM, Cal Dershowitz wrote:
> 
>>> So does php have a way to do this that is as simple as it might be in
>>> perl, for example?
>>
>> Sure, you *can* do it in PHP.  But if you have a working bash script,
>> why reinvent the wheel?  Especially since it sounds like you don't know
>> much about PHP.
>>
> 
> Well, if I can't invoke random behavior, I can't think that I have any
> Thuring-compliant medium.
> 
> It's to be taken as a learning-example.  I can accomplish this in every
> syntax I know.  I'd like to accomplish this in one I don't.

Have a look at these functions for starters:

rand()
array_rand()
shuffle()

-- 
Cheers
David Robley

It is bad luck to be superstitious.

[toc] | [prev] | [next] | [standalone]


#8524

FromCal Dershowitz <cal@example.invalid>
Date2013-03-03 18:59 -0800
Message-ID<kfmdnRPcNqyIk6nMnZ2dnUVZ_hudnZ2d@supernews.com>
In reply to#8515
On 02/28/2013 10:54 PM, David Robley wrote:

> Have a look at these functions for starters:
>
> rand()
> array_rand()
> shuffle()
>

Alright, David, I'm pleased with how far I've gotten with this so far

$ pwd
/var/www
$ ls
CCE0-705F  index.html  read_dir1.php   read_dir3.php   read_dir5.php
date.php   music1      read_dir1.php~  read_dir3.php~  read_dir5.php~
date.php~  music1.sh   read_dir2.php   read_dir4.php   test.php
hello.php  music1.sh~  read_dir2.php~  read_dir4.php~  Untitled Document
$ cat read_dir4.php
<?php

function getFilesFromDir($dir) {

   $files = array();
   if ($handle = opendir($dir)) {
     while (false !== ($file = readdir($handle))) {
         if ($file != "." && $file != "..") {
             if(is_dir($dir.'/'.$file)) {
                 $dir2 = $dir.'/'.$file;
                 $files[] = getFilesFromDir($dir2);
             }
             else {
               $files[] = $dir.'/'.$file;
             }
         }
     }
     closedir($handle);
   }

   return array_flat($files);
}

function array_flat($array) {

   foreach($array as $a) {
     if(is_array($a)) {
       $tmp = array_merge($tmp, array_flat($a));
     }
     else {
       $tmp[] = $a;
     }
   }

   return $tmp;
}

// Usage
$dir = 'music1';
$foo = getFilesFromDir($dir);

print_r($foo);
?>
$

This is my fourth version of this script, obviously written primarily by 
someone with more experience.

The output is tremendous, and the next step is to use a regex to knock 
off leading numbers and underscores.  I have a simple question.

Given that you have the data in an array that is instantiated like this, 
how does one use best php form to use a regex on the whole thing?
-- 
Cal

[toc] | [prev] | [next] | [standalone]


#8530 — getting perl and php to talk to each other, was Re: randomly sorting files in php

FromCal Dershowitz <cal@example.invalid>
Date2013-03-05 01:19 -0800
Subjectgetting perl and php to talk to each other, was Re: randomly sorting files in php
Message-ID<3b-dnfsjxuAJJajMnZ2dnUVZ_qCdnZ2d@supernews.com>
In reply to#8524
[x-posted to clp.misc]

On 03/03/2013 06:59 PM, Cal Dershowitz wrote:

> On 02/28/2013 10:54 PM, David Robley wrote:
>
>> Have a look at these functions for starters:
>>
>> rand()
>> array_rand()
>> shuffle()
>>
>
> Alright, David, I'm pleased with how far I've gotten with this so far
>
> $ pwd
> /var/www
> $ ls
> CCE0-705F  index.html  read_dir1.php   read_dir3.php   read_dir5.php
> date.php   music1      read_dir1.php~  read_dir3.php~  read_dir5.php~
> date.php~  music1.sh   read_dir2.php   read_dir4.php   test.php
> hello.php  music1.sh~  read_dir2.php~  read_dir4.php~  Untitled Document
> $ cat read_dir4.php
> <?php
>
> function getFilesFromDir($dir) {
>
>    $files = array();
>    if ($handle = opendir($dir)) {
>      while (false !== ($file = readdir($handle))) {
>          if ($file != "." && $file != "..") {
>              if(is_dir($dir.'/'.$file)) {
>                  $dir2 = $dir.'/'.$file;
>                  $files[] = getFilesFromDir($dir2);
>              }
>              else {
>                $files[] = $dir.'/'.$file;
>              }
>          }
>      }
>      closedir($handle);
>    }
>
>    return array_flat($files);
> }
>
> function array_flat($array) {
>
>    foreach($array as $a) {
>      if(is_array($a)) {
>        $tmp = array_merge($tmp, array_flat($a));
>      }
>      else {
>        $tmp[] = $a;
>      }
>    }
>
>    return $tmp;
> }
>
> // Usage
> $dir = 'music1';
> $foo = getFilesFromDir($dir);
>
> print_r($foo);
> ?>
> $
>
> This is my fourth version of this script, obviously written primarily by
> someone with more experience.
>
> The output is tremendous, and the next step is to use a regex to knock
> off leading numbers and underscores.  I have a simple question.
>
> Given that you have the data in an array that is instantiated like this,
> how does one use best php form to use a regex on the whole thing?

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

The install didn't succumb to my first try, nor the second, which was this:

cpan[1]> install PHP::Interpreter
Going to read '/home/fred/.cpan/Metadata'
   Database was generated on Mon, 28 Jan 2013 12:06:54 GMT
Fetching with LWP:
http://cpan.cs.utah.edu/authors/01mailrc.txt.gz
...

so far so good, and then this thing which I've seen in the literature:

using php_config 'php-config'
Can't exec "php-config": No such file or directory at Makefile.PL line 55.
Failed to find the 'php-config' executable. Make sure you have PHP and 
PHP sources installed, and that 'php-config' is in PATH. at Makefile.PL 
line 55.
...

bla bla bla do not pass Go.  Right now I have a default installation.

Simple question:  What types of things can I get configured with 
php-config?  envelope data available?  ftp data?
-- 
Cal

[toc] | [prev] | [next] | [standalone]


#8531 — Re: getting perl and php to talk to each other, was Re: randomly sorting files in php

From"M. Strobel" <sorry_no_mail_here@nowhere.dee>
Date2013-03-05 19:43 +0100
SubjectRe: getting perl and php to talk to each other, was Re: randomly sorting files in php
Message-ID<apmsmvFrlnnU1@mid.uni-berlin.de>
In reply to#8530
Am 05.03.2013 10:19, schrieb Cal Dershowitz:
> 
> 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 not instantiate a Lua interpreter in perl? Or Ruby? And the picture on the
provided links show _who_ is doing that.

Now, seriously, this is of limited use.

/Str.

[toc] | [prev] | [next] | [standalone]


#8532 — Re: getting perl and php to talk to each other, was Re: randomly sorting files in php

FromThe Natural Philosopher <tnp@invalid.invalid>
Date2013-03-05 19:20 +0000
SubjectRe: getting perl and php to talk to each other, was Re: randomly sorting files in php
Message-ID<kh5gh5$jp4$2@news.albasani.net>
In reply to#8531
On 05/03/13 18:43, M. Strobel wrote:
> Am 05.03.2013 10:19, schrieb Cal Dershowitz:
>>
>> 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 not instantiate a Lua interpreter in perl? Or Ruby? And the picture on the
> provided links show _who_ is doing that.
>
> Now, seriously, this is of limited use.
>
> /Str.
>
I am sure there is a huge market for anything that can translate between 
Gaelic and Linear B.

Someone told me so, when they were trying to raise the capital:-)

-- 
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.

[toc] | [prev] | [next] | [standalone]


#8533 — Re: getting perl and php to talk to each other

FromBen Morrow <ben@morrow.me.uk>
Date2013-03-05 22:06 +0000
SubjectRe: getting perl and php to talk to each other
Message-ID<sr6i0a-mdq1.ln1@anubis.morrow.me.uk>
In reply to#8530
Quoth Cal Dershowitz <cal@example.invalid>:
> [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.

Note that the Perl in that article (or at least, the first page, which
was all I read) is pretty bad:

    - use of global filehandles, unnecessary since 2000,
    - use of Thread.pm, deprecated since 2002,
    - use of threads at all for such a trivial problem,
    - using rindex and substr rather than pattern matching,
    - using backticks instead of system(),
    - 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, 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).

> so far so good, and then this thing which I've seen in the literature:
> 
> using php_config 'php-config'
> Can't exec "php-config": No such file or directory at Makefile.PL line 55.
> Failed to find the 'php-config' executable. Make sure you have PHP and 
> PHP sources installed, and that 'php-config' is in PATH. at Makefile.PL 
> line 55.
> ...
> 
> bla bla bla do not pass Go.  Right now I have a default installation.
> 
> Simple question:  What types of things can I get configured with 
> php-config?  envelope data available?  ftp data?

php-config is a program installed with php, which tells other programs
how php was installed. For instance, on my system

    ~% php-config --libs
    -lcrypt -lcrypt -lpcre -lm -lxml2 -lz -liconv -lm -lcrypt -lcrypt
    ~% php-config --includes
    -I/usr/local/include/php -I/usr/local/include/php/main
    -I/usr/local/include/php/TSRM -I/usr/local/include/php/Zend
    -I/usr/local/include/php/ext -I/usr/local/include/php/ext/date/lib
    ~%

and so on. If you've installed php properly (including any required
development packages, if you're using a package system), you should have
a php-config executable somewhere. Make sure it's in your PATH before
running Makefile.PL.

Ben

[toc] | [prev] | [next] | [standalone]


#8534 — Re: getting perl and php to talk to each other

FromThomas 'PointedEars' Lahn <PointedEars@web.de>
Date2013-03-06 00:20 +0100
SubjectRe: getting perl and php to talk to each other
Message-ID<2933000.lxfid8jaWL@PointedEars.de>
In reply to#8533
[X-Post & F'up2 comp.lang.php; please do not X-Post without F'up2]

Ben Morrow wrote:

> Quoth Cal Dershowitz <cal@example.invalid>:
>> [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$8300dec7@news.demon.co.uk>

[toc] | [prev] | [next] | [standalone]


#8535 — Re: getting perl and php to talk to each other

FromBen Morrow <ben@morrow.me.uk>
Date2013-03-05 23:59 +0000
SubjectRe: getting perl and php to talk to each other
Message-ID<jgdi0a-49r1.ln1@anubis.morrow.me.uk>
In reply to#8534
Quoth Thomas 'PointedEars' Lahn <php@PointedEars.de>:
> [X-Post & F'up2 comp.lang.php; please do not X-Post without F'up2]

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

> Ben Morrow wrote:
> > Quoth Cal Dershowitz <cal@example.invalid>:
> >> [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.  

Yes, of course.

> 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.

> > 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.

> > 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

[toc] | [prev] | [next] | [standalone]


#8536 — Re: getting perl and php to talk to each other

FromThe Natural Philosopher <tnp@invalid.invalid>
Date2013-03-06 01:01 +0000
SubjectRe: getting perl and php to talk to each other
Message-ID<kh64gv$4p2$1@news.albasani.net>
In reply to#8535
It's bad enough having to wrote what amounts to JavaScript, SQL and PHP 
in the same program without adding PERL..

I dunno why people always want to make things needlessly complicated. 
Obviously they are being paid to much and are not given enough work to do/.

My Linus system is already full of crap I really would prefer not to 
have, PERL, python.. all modern equivalents of MS BASIC.



-- 
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.

[toc] | [prev] | [next] | [standalone]


#8537 — Re: getting perl and php to talk to each other

FromJerry Stuckle <jstucklex@attglobal.net>
Date2013-03-05 20:08 -0500
SubjectRe: getting perl and php to talk to each other
Message-ID<kh64r2$fa4$1@dont-email.me>
In reply to#8535
On 3/5/2013 6:59 PM, Ben Morrow wrote:
>
> Quoth Thomas 'PointedEars' Lahn <php@PointedEars.de>:
>> [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.
jstucklex@attglobal.net
==================

[toc] | [prev] | [next] | [standalone]


#8552 — Re: getting perl and php to talk to each other

FromCal Dershowitz <cal@example.invalid>
Date2013-03-06 22:37 -0800
SubjectRe: getting perl and php to talk to each other
Message-ID<KZ-dnfo_fuUuqKXMnZ2dnUVZ_s6dnZ2d@supernews.com>
In reply to#8537
On 03/05/2013 05:08 PM, Jerry Stuckle wrote:
> On 3/5/2013 6:59 PM, Ben Morrow wrote:

>>>> 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.

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.
>
> Or, perhaps you need to build the data preprocessor, and aren't familiar
> with the language the package is written in.

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.
>
> 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?
>
>>> 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.

No, nothing like that complex.

[snip]

[OT]
> 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.
>

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.

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.
-- 
Cal

[toc] | [prev] | [next] | [standalone]


#8554 — Re: getting perl and php to talk to each other

FromBen Morrow <ben@morrow.me.uk>
Date2013-03-07 06:57 +0000
SubjectRe: getting perl and php to talk to each other
Message-ID<vbql0a-44v2.ln1@anubis.morrow.me.uk>
In reply to#8552
Quoth Cal Dershowitz <cal@example.invalid>:
> 
> 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.

> 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

[toc] | [prev] | [next] | [standalone]


#8556 — Re: getting perl and php to talk to each other

FromCal Dershowitz <cal@example.invalid>
Date2013-03-07 00:52 -0800
SubjectRe: getting perl and php to talk to each other
Message-ID<0a2dnd985Zb0yKXMnZ2dnUVZ_rWdnZ2d@supernews.com>
In reply to#8554
On 03/06/2013 10:57 PM, Ben Morrow wrote:
>
> Quoth Cal Dershowitz <cal@example.invalid>:
>>
>> 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?

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?
-- 
Cal

[toc] | [prev] | [next] | [standalone]


#8561 — Re: getting perl and php to talk to each other

FromJerry Stuckle <jstucklex@attglobal.net>
Date2013-03-07 08:17 -0500
SubjectRe: getting perl and php to talk to each other
Message-ID<kha3uo$amk$1@dont-email.me>
In reply to#8556
On 3/7/2013 3:52 AM, Cal Dershowitz wrote:
> On 03/06/2013 10:57 PM, Ben Morrow wrote:
>>
>> Quoth Cal Dershowitz <cal@example.invalid>:
>>>
>>> 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.
jstucklex@attglobal.net
==================

[toc] | [prev] | [next] | [standalone]


#8655 — Re: getting perl and php to talk to each other

FromCal Dershowitz <cal@example.invalid>
Date2013-03-14 03:41 -0700
SubjectRe: getting perl and php to talk to each other
Message-ID<r_Odna1OFYHDNNzMnZ2dnUVZ_qGdnZ2d@supernews.com>
In reply to#8561
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 <cal@example.invalid>:
>>>>
>>>> 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.  Fuck off.
-- 
Cal

[toc] | [prev] | [next] | [standalone]


#8658 — Re: getting perl and php to talk to each other

FromThe Natural Philosopher <tnp@invalid.invalid>
Date2013-03-14 11:14 +0000
SubjectRe: getting perl and php to talk to each other
Message-ID<khsbee$t4h$2@news.albasani.net>
In reply to#8655
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 <cal@example.invalid>:
>>>>>
>>>>> 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.  Fuck 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.

[toc] | [prev] | [next] | [standalone]


#8662 — Re: getting perl and php to talk to each other

FromJerry Stuckle <jstucklex@attglobal.net>
Date2013-03-14 08:06 -0400
SubjectRe: getting perl and php to talk to each other
Message-ID<khsecn$ol2$2@dont-email.me>
In reply to#8658
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 <cal@example.invalid>:
>>>>>>
>>>>>> 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.  Fuck 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.
jstucklex@attglobal.net
==================

[toc] | [prev] | [next] | [standalone]


Page 1 of 3  [1] 2 3  Next page →

Back to top | Article view | comp.lang.php


csiph-web