Since you are using a command line option to specify the delimiter, let me suggest that you try avoiding the use of quotemeta -- even though this happens to be the shortest answer to your original question.

Instead, provide the delimiter string on the command line in such a way that it will be properly interpreted within the script. For example, in bash (or other unix/bourne-like shell), you could do:

your_script -d '\|' foo bar
(or whatever the command line is supposed to look like) -- note that quotation marks are placed around the delimiter string, so that the backslash and vertical bar are passed to the script without being interpreted by the shell. If your script does not use quotemeta, then the regex for the split will be:
/\|/
which is exactly what you want. Now, suppose you really want to use some "magic" regex characters for your delimiter string... e.g. your input file has lines like this:
foo:bar;baz;blork blix etc foo2:bar3;bazx;blrk blx and-so-on
and you need to split on colon, semi-colon and space. The command-line option for the delimiter would then be:
your_script -d '[:; ]' that.file
If you used quotemeta on the delimiter string inside your script, this sort of flexibility would not be possible.

In reply to Re: problem with split function by graff
in thread problem with split function by jclaudio

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.