I am reading another perl file line by line and need to find any words or set of words surround by single or double quotations. This is an example of the code I am reading i
Maybe you can have more than one "string" to capture per line, one solution could be:
while(my $line=) {
while( $line =~ /[\'\"](.*?)[\'\"]/g ) {
print "matched: '$1'\n";
}
}
ie, input:
#!/usr/bin/env perl
use strict;
use warnings;
my $string = 'Hello World!' . 'asdsad';
print "$string\n";
and executing the code will give you:
matched: 'Hello World!'
matched: 'asdsad'
matched: '$string\n'