On 16/12/2014 20:05, Kenneth Wolcott 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 > Rather than attempting to parse the human-readable output from VBoxManage, have you instead tried the --machinereadable option?:
VBoxManage showvminfo <uuid|vmname> --machinereadable You could then try using an INI file parser to parse the result: use Config::Tiny; my $info = `VBoxManage showvminfo "<uuid|vmname>" --machinereadable`; my $config = Config::Tiny->read_string($info); -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/