fork download
  1. #!/usr/bin/perl
  2. # your code goes here
  3.  
  4. use strict;
  5. use warnings;
  6. use Data::Dumper;
  7.  
  8. my $v = q/
  9. foo "bar" baz
  10. foo 'bar' baz
  11. foo '!bar" baz
  12. foo !bar bas
  13. /;
  14.  
  15. if (my @l = $v =~ m/'([^']*)'|"([^"]*)"/g) {
  16. print '>>> matched ' . Dumper(\@l);
  17. }
Success #stdin #stdout 0.02s 5056KB
stdin
Standard input is empty
stdout
>>> matched $VAR1 = [
          undef,
          'bar',
          'bar',
          undef
        ];