#!/usr/bin/perl -w use strict; use Text::Balanced qw( extract_quotelike ); for ( 'O\'Reilly, \'Tim\' "Timmy"', 'q # an octothorpe: \# (not the end of the q!) #', "'SELECT name FROM DUAL;'", ' "You said, \"Use sed\"." ', ) { my ($extracted, $remainder) = extract_quotelike; print "STRING: $_\n"; print " TOOK: $extracted\n"; print " LEFT: $remainder\n"; print " ERROR: $@->{error}\n" if $@; }