I thought Text::Balanced might be an appropriate module to use here but I haven't used it before. The following test indicates suitablility for your application; other monks (who might have used this module more than once) may have better ways of doing this.
#!/usr/bin/env perl use 5.010; use strict; use warnings; use Text::Balanced qw{extract_multiple gen_delimited_pat}; my $in_string = q{qwe asd 'rty uio p' zxc "vbnm fghj" 123 4 ' @ & '}; my @tokens = extract_multiple($in_string => [ q{ }, gen_delimited_pat(q{'"}) ]); for my $token (@tokens) { next if $token eq q{ }; $token =~ y{'"}{}d; say $token; }
Output:
qwe asd rty uio p zxc vbnm fghj 123 4 @ &
-- Ken
In reply to Re: Help with search query
by kcott
in thread Help with search query
by htmanning
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |