On Tue, Dec 16, 2014 at 12:18 PM, Tiago Hori <tiago.h...@gmail.com> wrote: > Have you tried Text::CSV_XS? It allows you to set both the separatist and eol > and it also lets you use complex separators. > > T. > > Sent from my iPhone > >> On Dec 16, 2014, at 4:05 PM, Kenneth Wolcott <kennethwolc...@gmail.com> >> wrote: >> >> Hi; >> >> I've got some strings that I need to parse the value(s) off of the key. >> >> The key is (possibly) space-separated and terminate by a colon, and >> the value is delimited by single quotes. But there are (potentially) >> additional values for the key. >> >> Here is one real-world example (excerpt from the output of VBoxManage >> showvminfo vm): >> Name: 'tuba', Host path: '/Users/kwolcott/Shared/tuba' (machine >> mapping), writable >> >> What I want to parse is the part contained by single quotes. >> >> Perhaps I'd better use a capturing regex instead of split? >> >> Perhaps something like: >> $example_string =~ m|'($1)'|; >> $shared_folder = $1; >> >> Is there a better way to do this? >> >> What kind of string format is this called? >> >> Thanks, >> Ken Wolcott
Well, I had to look at http://perldoc.perl.org/perlrequick.html#Extracting-matches to find out how much I had forgotten about extracting matches from a regex :-) This might be inefficient, but it seems to work: $shared_folder =~ m|\'([-A-Za-z/_]+)\'.+'([-A-Za-z/_]+)\'|; print $2 . "\n"; Would be good to come up with something better, hopefully... Thanks, Ken -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/