Text::ParseWords

Discussion in 'Perl Misc' started by howa, Nov 11, 2008.

  1. howa

    howa Guest

    Consider the codes:


    #=====================
    use Text::parseWords;
    use Data::Dumper;

    my $query =qq^"abc def" filetype:pdf def 'xyz 123' '^;
    @new = parse_line(" ", 0, $query);
    print Dumper @new;
    #=====================

    It cannot split the string,

    But if ...

    my $query =qq^"abc def" filetype:pdf def 'xyz 123' ''^;

    Then it is ok, i.e.

    $VAR1 = 'abc def';
    $VAR2 = 'filetype:pdf';
    $VAR3 = 'def';
    $VAR4 = 'xyz 123';
    $VAR5 = '';


    Any comments?
    howa, Nov 11, 2008
    #1
    1. Advertising

  2. howa <> wrote:
    > Consider the codes:
    > #=====================
    > use Text::parseWords;
    > use Data::Dumper;
    >
    > my $query =qq^"abc def" filetype:pdf def 'xyz 123' '^;


    You have an item (the last one) with an unbalanced number of quotes.

    > But if ...
    >
    > my $query =qq^"abc def" filetype:pdf def 'xyz 123' ''^;


    Here you've balanced them.

    Seems it is identical to :

    parse_line(" ", 0, qq^'^);

    It appears that parse_line returns false if the quotes do not balance.

    --
    Darren
    Darren Dunham, Nov 14, 2008
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. leo
    Replies:
    1
    Views:
    266
    Bob Lehmann
    Dec 5, 2005
  2. Keith A. Clay

    issue with Text::ParseWords

    Keith A. Clay, Jun 23, 2005, in forum: Perl Misc
    Replies:
    0
    Views:
    90
    Keith A. Clay
    Jun 23, 2005
  3. tsotsi

    Text::ParseWords::parse_line bug?

    tsotsi, Jul 28, 2006, in forum: Perl Misc
    Replies:
    2
    Views:
    193
    -berlin.de
    Jul 30, 2006
  4. ccc31807

    Text::ParseWords

    ccc31807, Mar 30, 2010, in forum: Perl Misc
    Replies:
    6
    Views:
    208
  5. ccc31807

    understanding regexp, Text::ParseWords

    ccc31807, Nov 5, 2010, in forum: Perl Misc
    Replies:
    2
    Views:
    151
    ccc31807
    Nov 5, 2010
Loading...

Share This Page