Text::ParseWords

H

howa

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?
 
D

Darren Dunham

howa said:
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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top