Hi,

It's my first time playing with Text::Balanced module. From the code below (a quick test script I wrote..), shouldn't $next contain '#name#' after the call to extract_delimited() sub?

As of now, the subroutine simply sets $@ indicating this: "Not a delimited pattern, detected at offset 0".

My thinking was that the extract_delimited() sub would pull out 'first' delimited substring inside a given larger string. This is not the case, however ;-). So, for that matter, how do I do it using this module? I'm not sure which one of the imported methods I should use to achive the desired result (say, pull out next '#' delimited substring).
use Text::Balanced qw ( extract_delimited extract_bracketed extract_quotelike extract_codeblock extract_variable extract_tagged extract_multiple gen_delimited_pat gen_extract_tagged ); my $source = 'Hello World, #name#!'; my ($cfml_expr_match, $next); #eval { $cfml_expr_match = gen_delimited_pat(q{#},q{#}); $next = extract_delimited($source, '#', '', '#'); #}; if ($@) { print "Hmm.. got this: $@\n"; } # some code here... print "\n";


Note: I've uncommented eval{...} since it would clear the $@ variable, therefore, not letting me to check on the status of a call to a Text::Balanced method. Any idea why this is a case? Sorry for yet another loosely related question ;-).

"There is no system but GNU, and Linux is one of its kernels." -- Confession of Faith

Edit kudra, 2002-01-10 Changed Delimited to Balanced in title per ntc request


In reply to using Text::Balanced... by vladb

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.