Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > Text::ParseWords

Reply
Thread Tools

Text::ParseWords

 
 
howa
Guest
Posts: n/a
 
      11-11-2008
Consider the codes:


#=====================
use Text:arseWords;
use Data:umper;

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

It cannot split the string,

But if ...

my $query =qq^"abc def" filetypedf def 'xyz 123' ''^;

Then it is ok, i.e.

$VAR1 = 'abc def';
$VAR2 = 'filetypedf';
$VAR3 = 'def';
$VAR4 = 'xyz 123';
$VAR5 = '';


Any comments?
 
Reply With Quote
 
 
 
 
Darren Dunham
Guest
Posts: n/a
 
      11-14-2008
howa <(E-Mail Removed)> wrote:
> Consider the codes:
> #=====================
> use Text:arseWords;
> use Data:umper;
>
> my $query =qq^"abc def" filetypedf def 'xyz 123' '^;


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

> But if ...
>
> my $query =qq^"abc def" filetypedf 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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off




Advertisments