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

  1. using regular expression

    my @files; while (my $line = <>) {         if (m/"([^"]+)"/) {                 push @files, $1;         } } 
  2. using split()

    my @files; while (my $line = <>) {         (undef, $file, undef) = split /"/, $line, 3;         push @files, $file; } 

Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -