.... # $sock returns lots of lines like these: "garbage garbage 'important_info' garbage 'important_info' garbage". # what I need is a way to save both the values inside the ''s on each line into their own variables. But how? # So far I've only found a way to save the first one: while(my $out = <$sock>) { if($out =~ /SELECT/) # only care about lines that mention SELECT { chop $out; $out =~ m/'(.*?)'/g; print "argument one: $1\n"; } } ....