#!/usr/bin/perl
use strict;
use warnings;
while($_=<DATA>){
if (/^\[Note\]\w+,(\w+)/){
my $x =$1;
print "$x\n";
}
}
__DATA__
[Note]note_values,notes_values2
[Book]novels,magazines
A couple of comments:
- use strict and use warnings even on a little script they will often catch a simple error that your eyes will gloss over "seeing what I meant to write"
- $x=~/^\[Note\](\w+)/; tries to match the regex in $x
- I think it does what you're looking for, if I read your question correctly