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

Does Perl have some php equivalents?

by pikablu (Initiate)
on Aug 12, 2007 at 05:11 UTC ( #632012=perlquestion: print w/replies, xml ) Need Help??

pikablu has asked for the wisdom of the Perl Monks concerning the following question:

This node falls below the community's threshold of quality. You may see it by logging in.

Replies are listed 'Best First'.
Re: Does Perl have some php equivalents?
by shmem (Chancellor) on Aug 12, 2007 at 06:07 UTC
    You are supposed to use DBI. See Tutorials, section Database Programming and gmax homenode for more information on database programming with perl.

    --shmem

    _($_=" "x(1<<5)."?\n".q·/)Oo.  G°\        /
                                  /\_¯/(q    /
    ----------------------------  \__(m.====·.(_("always off the crowd"))."·
    ");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}
Re: Does Perl have some php equivalents?
by ysth (Canon) on Aug 12, 2007 at 06:13 UTC
    You might want to say what mail(), empty(), and exists() do in PHP, for those of us who don't know.

    To use mysql in Perl, you use the DBD::mysql database driver for the DBI database interface module.

Re: Does Perl have some php equivalents?
by Gangabass (Vicar) on Aug 12, 2007 at 09:17 UTC

    I think there is no need for PHP empty() in Perl.

    You can simply write:

    if ($var) { ... }

    For PHP mail() see various modules on CPAN, for example Net::SMTP.

Re: Does Perl have some php equivalents?
by jhourcle (Prior) on Aug 12, 2007 at 14:53 UTC

    What is the exists() function in php? There's array_key_exists(), class_exists(), dba_exists(), dbmexists(), file_exists(), function_exists(), interface_exists(), method_exists(), phar_offsetexists(), and property_exists().

    Others have already mentioned empty (just test for (! $var)) and mysql (DBD::mysql and DBI), but mail's a tricky one, as there are lots of different mail modules in CPAN. The question's been asked many, many times on here ... but typically, they mention part of their requirements ... MIME, message size, quantity. I don't know if there's a nice list of what the features are of each of 'em.

Re: PERL questions
by CountZero (Bishop) on Aug 13, 2007 at 06:03 UTC
    It's Perl, not PERL and the bane of PHP is that it has a multitude of functions, which seem to do almost the same thing but not quite. By the last count there were almost 700 functions!

    As an example there is:

    • mysql_connect which is defined as mysql_connect ( [string $ server [, string $ username [, string $ password [, bool $ new_link [, int $ client_flags ]]]]] ); and
    • mssql_connect which is defined as mssql_connect ( [string $servername [, string $username [, string $password [, bool $new_link]]]] )
    and yes, you have odbc_connect and odbc_pconnect if you need persistent connections and the whole lot of mysqli_* improved functions ("i" for improved) and for the Postgres users there is of course pg_connect which unfortunately has a totally different syntax.

    Perl has chosen not to go that way, but to provide a basic core of functions and core-modules extending the basic-functions and a multitude of modules which you can add when necessary. This keeps Perl as a language relatively small and clean, but allows for easy extension if and when necessary.

    If you want to start coding in Perl, don't try to code PHP in Perl.

    CountZero

    A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://632012]
Approved by Old_Gray_Bear
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (7)
As of 2022-01-28 11:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    In 2022, my preferred method to securely store passwords is:












    Results (73 votes). Check out past polls.

    Notices?