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. Advertisements

  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. Advertisements

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. Kelvin
    Replies:
    2
    Views:
    765
    Andrew Balmos (abalmos)
    Nov 9, 2004
  2. Jim Owen
    Replies:
    1
    Views:
    595
    Natty Gur
    Jul 24, 2003
  3. Jeremy Chapman

    Load contents of a text file into a text box

    Jeremy Chapman, Aug 15, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    883
    Tommy
    Aug 15, 2003
  4. leo
    Replies:
    1
    Views:
    482
    Bob Lehmann
    Dec 5, 2005
  5. Keith A. Clay

    issue with Text::ParseWords

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

    Text::ParseWords::parse_line bug?

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

    Text::ParseWords

    ccc31807, Mar 30, 2010, in forum: Perl Misc
    Replies:
    6
    Views:
    376
  8. ccc31807

    understanding regexp, Text::ParseWords

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