Please help me with my script please. I am trying to do the following:
1. Read files for the current directory
2. Open and read from nbe files files only
3. Read only the lines with the results pattern
4. Split the line and print 3rd field
Please indicate what line I need to modify. Thanks a bunch.
1 #!/usr/bin/perl -w
2 use strict;
3 use warnings;
4
5
6 # Open the current directory
7 my $directory = '.';
8
9 # Read from the current directory
10 opendir (DIR, $directory) or die "Folder not found: $1";
11
12
13 while (my $file = readdir(DIR)) {
14
15 if (my $File =~/\.nbe$/){
16
17 open (File, my $File) or die "Could not open NBE file:";
18
19 while (my $line = <FILE> )
20
21 if ($line =~/results/)
22
23 our @$values = split (/\|/, $line);
24
25 print my $values[3];
26 }
27
28 }
29
30 close(DIR);
Error Message:
syntax error at ./perlnbe_v2.pl line 30, near ")
if"
syntax error at ./perlnbe_v2.pl line 34, near "$values["
Execution of ./perlnbe_v2.pl aborted due to compilation errors.
Edit/Delete Message
1. Read files for the current directory
2. Open and read from nbe files files only
3. Read only the lines with the results pattern
4. Split the line and print 3rd field
Please indicate what line I need to modify. Thanks a bunch.
1 #!/usr/bin/perl -w
2 use strict;
3 use warnings;
4
5
6 # Open the current directory
7 my $directory = '.';
8
9 # Read from the current directory
10 opendir (DIR, $directory) or die "Folder not found: $1";
11
12
13 while (my $file = readdir(DIR)) {
14
15 if (my $File =~/\.nbe$/){
16
17 open (File, my $File) or die "Could not open NBE file:";
18
19 while (my $line = <FILE> )
20
21 if ($line =~/results/)
22
23 our @$values = split (/\|/, $line);
24
25 print my $values[3];
26 }
27
28 }
29
30 close(DIR);
Error Message:
syntax error at ./perlnbe_v2.pl line 30, near ")
if"
syntax error at ./perlnbe_v2.pl line 34, near "$values["
Execution of ./perlnbe_v2.pl aborted due to compilation errors.
Edit/Delete Message