Hi,
I'm new to perl and I'm stuck at regular expression on which to get the data of deck, super and trial from an array.
I have an input file as the following :
`deck {
@STATE = "this is low";
@ACCESS = "RW";
} [6:0];
super {
@STATE = "this is target";
@ACCESS = "RW";
} [3:3];
trial {
@STATE = "this is power";
@ACCESS = "RW";
} [5:4];`
Here is my code :
my $file1 = "in.txt";
my @array = ("deck", "super", "trial");
open (INPUT, "<", $file1) || die "\nError: File Read error\n";
my @input=<INPUT>;
close INPUT;
foreach my $line (@input) {
chomp $line;
$line =~ s/^\s+//;
$line =~ s/\s+$//;
my $pattern = $line;
my $info;
if (grep ( /^\w/i, @array ) ) {
$info = $pattern;
print ($info);
}
}
I supposed to have an output of the following :
Info State Access Address
deck This is low RW [6:0]