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

is there any "implode" and "explode" functions in perl ? if yes, in which module ?

Edited by Arunbear: Changed title from 'implode', as per Monastery guidelines

  • Comment on Where can I find the 'implode' and 'explode' functions?

Replies are listed 'Best First'.
Re: Where can I find the 'implode' and 'explode' functions?
by Corion (Patriarch) on May 12, 2005 at 08:26 UTC

    Your question is really unclear, but from the phrasing and use of PSI::ESP, I infer the following question:

    I am using PHP and PHP has the builtin functions implode and explode, which compress and decompress using the zlib library. Is there anything comparable in Perl?

    If that was your question, then the answer is "yes". The module Compress::Zlib contains functions that do the same.

Re: Where can I find the 'implode' and 'explode' functions?
by Zaxo (Archbishop) on May 12, 2005 at 08:16 UTC

    Quantum::Superpositions, among several of TheDamian's opus, is known to cause the user's head to explode. I never heard of any implosions, though.

    After Compline,
    Zaxo

Re: Where can I find the 'implode' and 'explode' functions?
by Forsaken (Friar) on May 12, 2005 at 08:24 UTC
    If my extremely limited knowledge of php is correct, the corresponding(more or less) functions in perl would be join() and split() respectively.

    Remember rule one...

Re: Where can I find the 'implode' and 'explode' functions?
by sh1tn (Priest) on May 12, 2005 at 12:09 UTC
    explode is php immitation of Perl split.
    implode is php immitation of Perl join.


Re: Where can I find the 'implode' and 'explode' functions?
by ambrus (Abbot) on May 12, 2005 at 08:23 UTC

    Untested:

    sub explode { my($s) = @_; $s =~ /./gs; } sub implode { join "", @_; }

    Update: added /s flag to handle strings with newlines. (The OP might never notice, I can't msg him.)

Re: Where can I find the 'implode' and 'explode' functions?
by BrowserUk (Patriarch) on May 12, 2005 at 08:27 UTC

    I assume that this is a reference to one or other of the compression formats?

    If so, you might like to update your post to indicate which type of compression utility you are interested in.

    Eg. ZIP, ARC, LHC, GZIP, BZ, BZ2 etc.


    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
    "Science is about questioning the status quo. Questioning authority".
    The "good enough" maybe good enough for the now, and perfection maybe unobtainable, but that should not preclude us from striving for perfection, when time, circumstance or desire allow.
Re: Where can I find the 'implode' and 'explode' functions?
by thcsoft (Monk) on May 12, 2005 at 12:25 UTC
    think perl! ;)

    language is a virus from outer space.