- Text::Balanced をインストールする。
bash-3.2$ /usr/local/bin/cpanm -f Text::Balanced --> Working on Text::Balanced Fetching http://search.cpan.org/CPAN/authors/id/A/AD/ADAMK/Text-Balanced-2.02.tar.gz ... OK Configuring Text-Balanced-2.02 ... OK Building and testing Text-Balanced-2.02 ... OK Successfully installed Text-Balanced-2.02 (upgraded from 2.0.0)
- text_balanced_sample01.pl
#!/usr/bin/env perl use strict; use warnings; use Text::Balanced qw(extract_quotelike); my $text = qq/ "SELECT ENAME FROM EMP" /; my ($extracted, $remainder) = extract_quotelike($text); print $extracted . "\n";
実行してみると、
bash-3.2$ ./text_balanced_sample01.pl "SELECT ENAME FROM EMP"
こんな感じ。