perl regex to read contents between double quotes -
i have file contains information this:
tag1 "file1.txt" some additional lines
tag2 "file2.txt" some more lines
tag3 "file3.txt". now, want read inside double quotes , assign variable ( $var1 = file1.txt $var2 = file2.txt $var3 = fil3.txt). can guild me how this.?
you achieve goal by
using regular expression
my @files; while (my $line = <>) { if (m/"([^"]+)"/) { push @files, $1; } }using
split()my @files; while (my $line = <>) { (undef, $file, undef) = split /"/, $line, 3; push @files, $file; }
Comments
Post a Comment